clan-core/clanModules/root-password/default.nix

21 lines
666 B
Nix
Raw Normal View History

2024-04-10 09:11:57 +00:00
{ pkgs, config, ... }:
{
users.mutableUsers = false;
2024-04-12 11:37:33 +00:00
users.users.root.hashedPasswordFile =
2024-06-17 10:42:28 +00:00
config.clan.core.facts.services.root-password.secret.password-hash.path;
sops.secrets."${config.clan.core.machineName}-password-hash".neededForUsers = true;
clan.core.facts.services.root-password = {
2024-04-10 09:11:57 +00:00
secret.password = { };
2024-04-12 11:37:33 +00:00
secret.password-hash = { };
2024-04-10 09:11:57 +00:00
generator.path = with pkgs; [
coreutils
xkcdpass
mkpasswd
];
generator.script = ''
xkcdpass --numwords 3 --delimiter - --count 1 | tr -d "\n" > $secrets/password
cat $secrets/password | mkpasswd -s -m sha-512 | tr -d "\n" > $secrets/password-hash
2024-04-10 09:11:57 +00:00
'';
};
}