Compare commits

..

2 Commits

Author SHA1 Message Date
Michael Hoang
da67da6f11 users: fix test 2025-07-16 12:03:19 +02:00
Jörg Thalheim
a417778a53 waypipe: disable gpu for now 2025-07-16 12:03:19 +02:00
7 changed files with 44 additions and 53 deletions

View File

@@ -4,13 +4,14 @@ let
in in
{ {
clan.modules.users = module; clan.modules.users = module;
perSystem = perSystem =
{ ... }: { ... }:
{ {
clan.nixosTests.users = { clan.nixosTests.users = {
imports = [ ./tests/vm/default.nix ]; imports = [ ./tests/vm/default.nix ];
clan.modules."@clan/users" = module; clan.modules.users = module;
}; };
}; };
} }

View File

@@ -2,50 +2,71 @@
name = "service-users"; name = "service-users";
clan = { clan = {
test.useContainers = false;
directory = ./.; directory = ./.;
inventory = { inventory = {
machines.server = { }; machines.machine = { };
instances = { instances = {
root-password-test = { users-root = {
module.name = "@clan/users"; module.name = "users";
module.input = "self"; module.input = "self";
roles.default.machines."server".settings = { roles.default.machines.machine.settings = {
user = "root"; user = "root";
prompt = false; prompt = false;
}; };
}; };
user-password-test = { users-testuser = {
module.name = "@clan/users"; module.name = "users";
module.input = "self"; module.input = "self";
roles.default.machines."server".settings = { roles.default.machines.machine.settings = {
user = "testuser"; user = "testuser";
prompt = false; prompt = false;
}; };
}; };
users-admin = {
module.name = "users";
module.input = "self";
roles.default.machines.machine.settings = {
user = "admin";
prompt = false;
groups = [ "wheel" ];
};
};
}; };
}; };
}; };
nodes = { nodes = {
server = { machine =
users.users.testuser.group = "testuser"; { pkgs, lib, ... }:
users.groups.testuser = { }; {
}; environment.systemPackages = [ pkgs.tree ]; # TODO: debug
clan.core.vars.generators.user-password-root.files.user-password.deploy = lib.mkForce true;
clan.core.vars.generators.user-password-testuser.files.user-password.deploy = lib.mkForce true;
};
}; };
testScript = '' testScript = ''
start_all() start_all()
server.wait_for_unit("multi-user.target") machine.wait_for_unit("multi-user.target")
# Check that the testuser account exists # Assert that the testuser exists
server.succeed("id testuser") machine.succeed("id testuser")
# Try to log in as the user using the generated password # TODO: debug
# TODO: fix machine.succeed("tree /run/secrets/vars")
# password = server.succeed("cat /run/clan/vars/user-password/user-password").strip()
# server.succeed(f"echo '{password}' | su - testuser -c 'echo Login successful'")
machine.fail("su - admin -c 'echo wrong-password | su - testuser -c \"echo Login successful\"'")
output = machine.succeed("sudo --reset-timestamp --stdin -u testuser echo Login successful < /run/secrets/vars/user-password-testuser/user-password")
assert output.strip() == "Login successful", f"Failed to log in as testuser: {output=}"
machine.fail("sudo --reset-timestamp --stdin -iu root echo Login successful < /run/secrets/vars/user-password-testuser/user-password")
output = machine.succeed("sudo --reset-timestamp --stdin -u root echo Login successful < /run/secrets/vars/user-password-root/user-password")
assert output.strip() == "Login successful", f"Failed to log in as root: {output=}"
''; '';
} }

View File

@@ -275,8 +275,6 @@ in
templates = lib.mkOption { type = lib.types.raw; }; templates = lib.mkOption { type = lib.types.raw; };
machines = lib.mkOption { type = lib.types.raw; }; machines = lib.mkOption { type = lib.types.raw; };
clan-cli = lib.mkOption { type = lib.types.raw; };
}; };
}; };
}; };

View File

@@ -273,9 +273,6 @@ in
# machine specifics # machine specifics
machines = configsPerSystem; machines = configsPerSystem;
# export clan-cli in clanInternals to tie the CLI to the flake
clan-cli = builtins.mapAttrs (_sys: pkgs: pkgs.clan-cli) clan-core.packages;
}; };
}; };
} }

View File

@@ -13,12 +13,7 @@
]; ];
perSystem = perSystem =
{ { config, pkgs, ... }:
config,
pkgs,
self',
...
}:
{ {
packages = { packages = {
agit = pkgs.callPackage ./agit { }; agit = pkgs.callPackage ./agit { };
@@ -33,25 +28,6 @@
classgen = pkgs.callPackage ./classgen { }; classgen = pkgs.callPackage ./classgen { };
zerotierone = pkgs.callPackage ./zerotierone { }; zerotierone = pkgs.callPackage ./zerotierone { };
update-clan-core-for-checks = pkgs.callPackage ./update-clan-core-for-checks { }; update-clan-core-for-checks = pkgs.callPackage ./update-clan-core-for-checks { };
clan-autorefresh = pkgs.symlinkJoin {
name = "clan";
paths = [
(pkgs.writeScriptBin "clan" ''
#!/bin/sh
set -efu
system=$(nix config show system)
nix \
--extra-experimental-features 'flakes nix-command' \
run ".#clanInternals.clan-cli.$system" -- "$@"
'')
self'.packages.clan-cli
];
postBuild = ''
rm -r $out/lib
'';
};
}; };
}; };
} }

View File

@@ -25,9 +25,7 @@
] ]
(system: { (system: {
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell { default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
packages = [ packages = [ clan-core.packages.${system}.clan-cli ];
clan-core.packages.${system}.clan-autorefresh
];
}; };
}); });
}; };

View File

@@ -28,7 +28,7 @@
perSystem = perSystem =
{ pkgs, inputs', ... }: { pkgs, inputs', ... }:
{ {
devShells.default = pkgs.mkShell { packages = [ inputs'.clan-core.packages.clan-autorefresh ]; }; devShells.default = pkgs.mkShell { packages = [ inputs'.clan-core.packages.clan-cli ]; };
}; };
}; };
} }