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
{
clan.modules.users = module;
perSystem =
{ ... }:
{
clan.nixosTests.users = {
imports = [ ./tests/vm/default.nix ];
clan.modules."@clan/users" = module;
clan.modules.users = module;
};
};
}

View File

@@ -2,50 +2,71 @@
name = "service-users";
clan = {
test.useContainers = false;
directory = ./.;
inventory = {
machines.server = { };
machines.machine = { };
instances = {
root-password-test = {
module.name = "@clan/users";
users-root = {
module.name = "users";
module.input = "self";
roles.default.machines."server".settings = {
roles.default.machines.machine.settings = {
user = "root";
prompt = false;
};
};
user-password-test = {
module.name = "@clan/users";
users-testuser = {
module.name = "users";
module.input = "self";
roles.default.machines."server".settings = {
roles.default.machines.machine.settings = {
user = "testuser";
prompt = false;
};
};
users-admin = {
module.name = "users";
module.input = "self";
roles.default.machines.machine.settings = {
user = "admin";
prompt = false;
groups = [ "wheel" ];
};
};
};
};
};
nodes = {
server = {
users.users.testuser.group = "testuser";
users.groups.testuser = { };
machine =
{ pkgs, lib, ... }:
{
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 = ''
start_all()
server.wait_for_unit("multi-user.target")
machine.wait_for_unit("multi-user.target")
# Check that the testuser account exists
server.succeed("id testuser")
# Assert that the testuser exists
machine.succeed("id testuser")
# Try to log in as the user using the generated password
# TODO: fix
# password = server.succeed("cat /run/clan/vars/user-password/user-password").strip()
# server.succeed(f"echo '{password}' | su - testuser -c 'echo Login successful'")
# TODO: debug
machine.succeed("tree /run/secrets/vars")
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; };
machines = lib.mkOption { type = lib.types.raw; };
clan-cli = lib.mkOption { type = lib.types.raw; };
};
};
};

View File

@@ -273,9 +273,6 @@ in
# machine specifics
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 =
{
config,
pkgs,
self',
...
}:
{ config, pkgs, ... }:
{
packages = {
agit = pkgs.callPackage ./agit { };
@@ -33,25 +28,6 @@
classgen = pkgs.callPackage ./classgen { };
zerotierone = pkgs.callPackage ./zerotierone { };
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: {
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
packages = [
clan-core.packages.${system}.clan-autorefresh
];
packages = [ clan-core.packages.${system}.clan-cli ];
};
});
};

View File

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