Compare commits
2 Commits
feat/clan-
...
updated
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89355a3cf6 | ||
|
|
77ea35119f |
@@ -14,6 +14,7 @@ in
|
||||
./installation/flake-module.nix
|
||||
./morph/flake-module.nix
|
||||
./nixos-documentation/flake-module.nix
|
||||
./update/flake-module.nix
|
||||
];
|
||||
perSystem =
|
||||
{
|
||||
@@ -46,6 +47,7 @@ in
|
||||
syncthing = import ./syncthing nixosTestArgs;
|
||||
zt-tcp-relay = import ./zt-tcp-relay nixosTestArgs;
|
||||
postgresql = import ./postgresql nixosTestArgs;
|
||||
update = import ./update nixosTestArgs;
|
||||
wayland-proxy-virtwl = import ./wayland-proxy-virtwl nixosTestArgs;
|
||||
};
|
||||
|
||||
|
||||
49
checks/update/default.nix
Normal file
49
checks/update/default.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
pkgs,
|
||||
self,
|
||||
clanLib,
|
||||
...
|
||||
}:
|
||||
clanLib.test.makeTestClan {
|
||||
inherit pkgs self;
|
||||
nixosTest = (
|
||||
{ lib, ... }:
|
||||
let
|
||||
machines = [
|
||||
"machine"
|
||||
];
|
||||
in
|
||||
{
|
||||
name = "update";
|
||||
|
||||
clan = {
|
||||
directory = ./.;
|
||||
inventory = {
|
||||
machines = lib.genAttrs machines (_: { });
|
||||
};
|
||||
};
|
||||
|
||||
defaults =
|
||||
{ ... }:
|
||||
{
|
||||
environment.systemPackages = [ self.packages.${pkgs.hostPlatform.system}.clan-cli-full ];
|
||||
services.openssh.enable = true;
|
||||
};
|
||||
|
||||
nodes = {
|
||||
machine-updated = {
|
||||
environment.etc."testfile".text = "updated";
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.wait_for_open_port(22)
|
||||
|
||||
machine.fail("cat /etc/testfile")
|
||||
machine.succeed("env CLAN_DIR=${self} clan machines update test-update-machine-${pkgs.hostPlatform.system} --debug")
|
||||
assert machine.succeed("cat /etc/testfile") == "updated"
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
||||
102
checks/update/flake-module.nix
Normal file
102
checks/update/flake-module.nix
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
self,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
clan.machines = lib.listToAttrs (
|
||||
lib.map (
|
||||
system:
|
||||
let
|
||||
configuration = self.checks.${system}.update.nodes.machine.system.build.extendModules { };
|
||||
in
|
||||
lib.nameValuePair "test-update-machine-${system}" {
|
||||
disabledModules = [ { key = "no-switch-to-configuration"; } ];
|
||||
|
||||
imports = configuration._module.args.modules ++ configuration._module.args.baseModules;
|
||||
|
||||
config = {
|
||||
_module.args = { inherit (configuration._module.args) name; };
|
||||
|
||||
networking.hostName = lib.mkForce "machine";
|
||||
clan.core.settings.machine.name = lib.mkForce "machine";
|
||||
|
||||
clan.core.networking.targetHost = "root@machine";
|
||||
|
||||
virtualisation.bootLoaderDevice = "/dev/vda";
|
||||
|
||||
environment.etc."testfile".text = "updated";
|
||||
};
|
||||
}
|
||||
) (lib.filter (lib.hasSuffix "linux") config.systems)
|
||||
);
|
||||
|
||||
perSystem =
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
checks = pkgs.lib.mkIf (pkgs.stdenv.isLinux && !pkgs.stdenv.isAarch64) {
|
||||
update = (import ../lib/test-base.nix) {
|
||||
name = "update";
|
||||
|
||||
nodes = {
|
||||
machine =
|
||||
{ pkgs, extendModules, ... }:
|
||||
let
|
||||
dependencies = [
|
||||
self
|
||||
pkgs.stdenv.drvPath
|
||||
pkgs.stdenvNoCC
|
||||
self.nixosConfigurations."test-update-machine-${pkgs.hostPlatform.system}".config.system.build.toplevel
|
||||
self.nixosConfigurations."test-update-machine-${pkgs.hostPlatform.system}".config.system.clan.deployment.file
|
||||
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
||||
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
||||
|
||||
inherit (import "${pkgs.path}/nixos/tests/ssh-keys.nix" pkgs)
|
||||
snakeOilEd25519PrivateKey
|
||||
snakeOilEd25519PublicKey
|
||||
;
|
||||
in
|
||||
{
|
||||
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
||||
system.extraDependencies = dependencies;
|
||||
virtualisation.memorySize = 2048;
|
||||
environment.systemPackages = [ self.packages.${pkgs.hostPlatform.system}.clan-cli-full ];
|
||||
system.build = { inherit extendModules; };
|
||||
|
||||
services.openssh.enable = true;
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
snakeOilEd25519PublicKey
|
||||
];
|
||||
|
||||
system.build.privateKey = snakeOilEd25519PrivateKey;
|
||||
};
|
||||
};
|
||||
testScript =
|
||||
{ nodes, ... }:
|
||||
let
|
||||
sshConfig = builtins.toFile "ssh.conf" ''
|
||||
UserKnownHostsFile=/dev/null
|
||||
StrictHostKeyChecking=no
|
||||
'';
|
||||
in
|
||||
''
|
||||
start_all()
|
||||
machine.wait_for_open_port(22)
|
||||
|
||||
machine.fail("${lib.getExe pkgs.tree} /dev/disk")
|
||||
|
||||
machine.succeed("install -Dm 600 ${nodes.machine.system.build.privateKey} ~root/.ssh/id_ed25519")
|
||||
machine.succeed("install ${sshConfig} ~root/.ssh/config")
|
||||
|
||||
machine.fail("cat /etc/testfile")
|
||||
machine.succeed("env CLAN_DIR=${self} clan machines update test-update-machine-${pkgs.hostPlatform.system} --debug")
|
||||
assert machine.succeed("cat /etc/testfile") == "updated"
|
||||
'';
|
||||
} { inherit pkgs self; };
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -117,7 +117,6 @@ in
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
readOnly = true;
|
||||
description = ''
|
||||
the name of the machine
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user