mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 15:11:34 +01:00
sops: generate the config with nix
This commit is contained in:
parent
021473a99d
commit
5e18975b9b
12 changed files with 85 additions and 74 deletions
|
|
@ -7,30 +7,36 @@
|
|||
}@moduleArgs:
|
||||
let
|
||||
cfg = config.custom.sops;
|
||||
|
||||
absoluteSecretsPath = "${self}/" + cfg.secretsFile;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.sops-nix.homeManagerModules.sops ];
|
||||
|
||||
options.custom.sops = {
|
||||
enable = lib.mkEnableOption "";
|
||||
agePublicKey = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
hostName = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = moduleArgs.osConfig.networking.hostName or "";
|
||||
};
|
||||
defaultSopsFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "${self}/users/${config.home.username}/@${cfg.hostName}/secrets.json";
|
||||
secretsFile = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "users/${config.home.username}/@${cfg.hostName}/secrets.json";
|
||||
};
|
||||
secrets = lib.mkOption {
|
||||
type = lib.types.anything;
|
||||
default = cfg.defaultSopsFile |> builtins.readFile |> builtins.fromJSON;
|
||||
default = absoluteSecretsPath |> builtins.readFile |> builtins.fromJSON;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
sops = {
|
||||
age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ];
|
||||
inherit (cfg) defaultSopsFile;
|
||||
defaultSopsFile = absoluteSecretsPath;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue