Refactor home-manager's defaultSopsFile definition

This commit is contained in:
SebastianStork 2025-07-16 20:02:53 +02:00
parent a401c0f4cf
commit 8ab4f4b9e1

View file

@ -5,20 +5,24 @@
lib, lib,
... ...
}@moduleArgs: }@moduleArgs:
let
cfg = config.custom.sops;
in
{ {
imports = [ inputs.sops-nix.homeManagerModules.sops ]; imports = [ inputs.sops-nix.homeManagerModules.sops ];
options.custom.sops.enable = lib.mkEnableOption ""; options.custom.sops = {
enable = lib.mkEnableOption "";
hostName = lib.mkOption {
type = lib.types.nonEmptyStr;
default = moduleArgs.osConfig.networking.hostName or "";
};
};
config = lib.mkIf config.custom.sops.enable { config = lib.mkIf cfg.enable {
sops = { sops = {
age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ]; age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ];
defaultSopsFile = defaultSopsFile = "${self}/users/${config.home.username}/${cfg.hostName}/secrets.yaml";
let
hostName = moduleArgs.osConfig.networking.hostName or "";
hostDir = if hostName != "" then "/@" + hostName else "";
in
"${self}/users/${config.home.username}${hostDir}/secrets.yaml";
}; };
}; };
} }