Compare commits
2 Commits
push-uymll
...
clan-autor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e18afbc5ea | ||
|
|
a04443adb8 |
@@ -4,14 +4,13 @@ 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.users = module;
|
clan.modules."@clan/users" = module;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,71 +2,50 @@
|
|||||||
name = "service-users";
|
name = "service-users";
|
||||||
|
|
||||||
clan = {
|
clan = {
|
||||||
test.useContainers = false;
|
|
||||||
directory = ./.;
|
directory = ./.;
|
||||||
inventory = {
|
inventory = {
|
||||||
machines.machine = { };
|
machines.server = { };
|
||||||
|
|
||||||
instances = {
|
instances = {
|
||||||
users-root = {
|
root-password-test = {
|
||||||
module.name = "users";
|
module.name = "@clan/users";
|
||||||
module.input = "self";
|
module.input = "self";
|
||||||
roles.default.machines.machine.settings = {
|
roles.default.machines."server".settings = {
|
||||||
user = "root";
|
user = "root";
|
||||||
prompt = false;
|
prompt = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
users-testuser = {
|
user-password-test = {
|
||||||
module.name = "users";
|
module.name = "@clan/users";
|
||||||
module.input = "self";
|
module.input = "self";
|
||||||
roles.default.machines.machine.settings = {
|
roles.default.machines."server".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 = {
|
||||||
machine =
|
server = {
|
||||||
{ pkgs, lib, ... }:
|
users.users.testuser.group = "testuser";
|
||||||
{
|
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()
|
||||||
|
|
||||||
machine.wait_for_unit("multi-user.target")
|
server.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
# Assert that the testuser exists
|
# Check that the testuser account exists
|
||||||
machine.succeed("id testuser")
|
server.succeed("id testuser")
|
||||||
|
|
||||||
# TODO: debug
|
# Try to log in as the user using the generated password
|
||||||
machine.succeed("tree /run/secrets/vars")
|
# 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'")
|
||||||
|
|
||||||
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=}"
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ 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; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -273,6 +273,9 @@ 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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,12 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
perSystem =
|
perSystem =
|
||||||
{ config, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
self',
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
agit = pkgs.callPackage ./agit { };
|
agit = pkgs.callPackage ./agit { };
|
||||||
@@ -28,6 +33,25 @@
|
|||||||
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
]
|
]
|
||||||
(system: {
|
(system: {
|
||||||
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
|
default = clan-core.inputs.nixpkgs.legacyPackages.${system}.mkShell {
|
||||||
packages = [ clan-core.packages.${system}.clan-cli ];
|
packages = [
|
||||||
|
clan-core.packages.${system}.clan-autorefresh
|
||||||
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
perSystem =
|
perSystem =
|
||||||
{ pkgs, inputs', ... }:
|
{ pkgs, inputs', ... }:
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell { packages = [ inputs'.clan-core.packages.clan-cli ]; };
|
devShells.default = pkgs.mkShell { packages = [ inputs'.clan-core.packages.clan-autorefresh ]; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user