mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-23 07:08:45 +08:00
31 lines
1.2 KiB
Nix
31 lines
1.2 KiB
Nix
inputs:
|
|
{
|
|
options.nixos.system.sops = let inherit (inputs.lib) mkOption types; in
|
|
{
|
|
enable = mkOption { type = types.bool; default = true; };
|
|
keyPathPrefix = mkOption { type = types.str; default = "/nix/persistent"; };
|
|
};
|
|
config = let inherit (inputs.config.nixos.system) sops; in inputs.lib.mkIf sops.enable
|
|
{
|
|
sops =
|
|
{
|
|
defaultSopsFile =
|
|
let deviceDir =
|
|
if (inputs.config.nixos.system.cluster == null) then
|
|
"${inputs.topInputs.self}/devices/${inputs.config.nixos.system.networking.hostname}"
|
|
else
|
|
"${inputs.topInputs.self}/devices/${inputs.config.nixos.system.cluster.clusterName}"
|
|
+ "/${inputs.config.nixos.system.cluster.nodeName}";
|
|
in inputs.lib.mkMerge
|
|
[
|
|
(inputs.lib.mkIf (builtins.pathExists "${deviceDir}/secrets.yaml") "${deviceDir}/secrets.yaml")
|
|
(inputs.lib.mkIf (builtins.pathExists "${deviceDir}/secrets/default.yaml")
|
|
"${deviceDir}/secrets/default.yaml")
|
|
];
|
|
# sops start before impermanence, so we need to use the absolute path
|
|
age.sshKeyPaths = [ "${sops.keyPathPrefix}/etc/ssh/ssh_host_ed25519_key" ];
|
|
gnupg.sshKeyPaths = [ "${sops.keyPathPrefix}/etc/ssh/ssh_host_rsa_key" ];
|
|
};
|
|
};
|
|
}
|