Files
nix/hosts/common/user/configs/console/sops/default.nix
2024-07-16 17:46:58 +03:00

26 lines
540 B
Nix

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