Files
nix/hosts/common/user/configs/console/sops/default.nix
2024-08-01 01:03:05 +03:00

25 lines
602 B
Nix

{
username ? throw "username argument is required",
}:
{
config,
inputs,
lib,
...
}:
let
userConfig = config.users.users.${username};
hmConfig = config.home-manager.users.${username};
sopsKeyPath = "${hmConfig.xdg.relativeConfigHome}/sops-nix/key.txt";
in
{
environment.persistence."/persist".users.${username}.files = [ sopsKeyPath ];
home-manager.users.${username} = {
imports = [ inputs.sops-nix.homeManagerModules.sops ];
sops.age.keyFile = "${userConfig.home}/${sopsKeyPath}";
home.sessionVariables.SOPS_AGE_KEY_FILE = "${userConfig.home}/${sopsKeyPath}";
};
}