mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 18:41:34 +01:00
38 lines
908 B
Nix
38 lines
908 B
Nix
{
|
|
config,
|
|
inputs,
|
|
self,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.custom.sops;
|
|
in
|
|
{
|
|
imports = [ inputs.sops.nixosModules.sops ];
|
|
|
|
options.custom.sops = {
|
|
enable = lib.mkEnableOption "";
|
|
agePublicKey = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "${self}/hosts/${config.networking.hostName}/keys/age.pub" |> lib.readFile |> lib.trim;
|
|
};
|
|
secretsFile = lib.mkOption {
|
|
type = lib.types.path;
|
|
default = "${self}/hosts/${config.networking.hostName}/secrets.json";
|
|
};
|
|
secrets = lib.mkOption {
|
|
type = lib.types.anything;
|
|
default = cfg.secretsFile |> lib.readFile |> lib.strings.fromJSON;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
sops = {
|
|
age.sshKeyPaths = [
|
|
"${lib.optionalString config.custom.persistence.enable "/persist"}/etc/ssh/ssh_host_ed25519_key"
|
|
];
|
|
defaultSopsFile = cfg.secretsFile;
|
|
};
|
|
};
|
|
}
|