mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 16:39:07 +01:00
tests: Refactor
This commit is contained in:
parent
33b2bed5a9
commit
8cf724fb97
3 changed files with 29 additions and 65 deletions
|
|
@ -5,22 +5,28 @@
|
||||||
let
|
let
|
||||||
mkTest = dir: rec {
|
mkTest = dir: rec {
|
||||||
name = "${dir}-test";
|
name = "${dir}-test";
|
||||||
value = pkgs.testers.runNixOSTest (
|
value = pkgs.testers.runNixOSTest {
|
||||||
{
|
inherit name;
|
||||||
inherit name;
|
imports = [ "${self}/tests/${dir}" ];
|
||||||
}
|
node.specialArgs = { inherit inputs self; };
|
||||||
// import "${self}/tests/${dir}" {
|
defaults =
|
||||||
inherit
|
{ nodes, ... }:
|
||||||
inputs
|
{
|
||||||
self
|
imports = [ self.nixosModules.default ];
|
||||||
pkgs
|
_module.args.allHosts = nodes |> lib.mapAttrs (_: node: { config = node; });
|
||||||
lib
|
users = {
|
||||||
;
|
mutableUsers = false;
|
||||||
}
|
users.seb = {
|
||||||
);
|
isNormalUser = true;
|
||||||
|
password = "seb";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
custom.networking.underlay.interface = "eth1";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
checks = "${self}/tests" |> builtins.readDir |> lib.attrNames |> lib.map mkTest |> lib.listToAttrs;
|
checks = "${self}/tests" |> self.lib.listDirectoryNames |> lib.map mkTest |> lib.listToAttrs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,16 @@
|
||||||
{
|
{
|
||||||
inputs,
|
|
||||||
self,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
node.specialArgs = { inherit inputs self; };
|
|
||||||
|
|
||||||
defaults =
|
defaults =
|
||||||
{ nodes, config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
imports = [ self.nixosModules.default ];
|
users.users.seb.openssh.authorizedKeys.keyFiles = lib.mkIf config.custom.services.sshd.enable [
|
||||||
|
./keys/server-ssh.pub
|
||||||
_module.args.allHosts = nodes |> lib.mapAttrs (_: node: { config = node; });
|
./keys/client1-ssh.pub
|
||||||
|
./keys/client2-ssh.pub
|
||||||
users = {
|
];
|
||||||
mutableUsers = false;
|
|
||||||
users.seb = {
|
|
||||||
isNormalUser = true;
|
|
||||||
password = "seb";
|
|
||||||
openssh.authorizedKeys.keyFiles = lib.mkIf config.custom.services.sshd.enable [
|
|
||||||
./keys/server-ssh.pub
|
|
||||||
./keys/client1-ssh.pub
|
|
||||||
./keys/client2-ssh.pub
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.etc."ssh-key" = lib.mkIf (lib.pathExists ./keys/${config.networking.hostName}-ssh) {
|
environment.etc."ssh-key" = lib.mkIf (lib.pathExists ./keys/${config.networking.hostName}-ssh) {
|
||||||
source = ./keys/${config.networking.hostName}-ssh;
|
source = ./keys/${config.networking.hostName}-ssh;
|
||||||
|
|
@ -39,7 +24,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.extraHosts = lib.mkForce "";
|
networking.extraHosts = lib.mkForce "";
|
||||||
services.resolved.dnssec = lib.mkForce "false";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
|
|
@ -52,7 +36,6 @@
|
||||||
role = "server";
|
role = "server";
|
||||||
};
|
};
|
||||||
underlay = {
|
underlay = {
|
||||||
interface = "eth1";
|
|
||||||
cidr = "192.168.0.1/16";
|
cidr = "192.168.0.1/16";
|
||||||
isPublic = true;
|
isPublic = true;
|
||||||
};
|
};
|
||||||
|
|
@ -73,7 +56,6 @@
|
||||||
role = "server";
|
role = "server";
|
||||||
};
|
};
|
||||||
underlay = {
|
underlay = {
|
||||||
interface = "eth1";
|
|
||||||
cidr = "192.168.0.2/16";
|
cidr = "192.168.0.2/16";
|
||||||
isPublic = true;
|
isPublic = true;
|
||||||
};
|
};
|
||||||
|
|
@ -91,10 +73,7 @@
|
||||||
address = "10.254.250.3";
|
address = "10.254.250.3";
|
||||||
role = "client";
|
role = "client";
|
||||||
};
|
};
|
||||||
underlay = {
|
underlay.cidr = "192.168.0.3/16";
|
||||||
interface = "eth1";
|
|
||||||
cidr = "192.168.0.3/16";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.openssh ];
|
environment.systemPackages = [ pkgs.openssh ];
|
||||||
|
|
@ -107,10 +86,7 @@
|
||||||
address = "10.254.250.4";
|
address = "10.254.250.4";
|
||||||
role = "client";
|
role = "client";
|
||||||
};
|
};
|
||||||
underlay = {
|
underlay.cidr = "192.168.0.4/16";
|
||||||
interface = "eth1";
|
|
||||||
cidr = "192.168.0.4/16";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.sshd.enable = true;
|
services.sshd.enable = true;
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,12 @@
|
||||||
{
|
{
|
||||||
inputs,
|
|
||||||
self,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
node.specialArgs = { inherit inputs self; };
|
|
||||||
|
|
||||||
defaults =
|
defaults =
|
||||||
{ nodes, config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
imports = [ self.nixosModules.default ];
|
|
||||||
|
|
||||||
_module.args.allHosts = nodes |> lib.mapAttrs (_: node: { config = node; });
|
|
||||||
|
|
||||||
users = {
|
|
||||||
mutableUsers = false;
|
|
||||||
users.seb = {
|
|
||||||
isNormalUser = true;
|
|
||||||
password = "seb";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
custom = {
|
custom = {
|
||||||
networking.underlay.interface = "eth1";
|
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
nebula = {
|
nebula = {
|
||||||
caCertificateFile = ./keys/nebula/ca.crt;
|
caCertificateFile = ./keys/nebula/ca.crt;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue