lib/flake-helper.nix: Automatically load sops secrets
This commit is contained in:
parent
63c60391cc
commit
22512de722
@ -45,8 +45,6 @@
|
||||
autoUpgrade = true;
|
||||
};
|
||||
|
||||
sops.secrets.wg-monitoring = {};
|
||||
|
||||
clerie.monitoring = {
|
||||
enable = true;
|
||||
id = "391";
|
||||
|
@ -54,8 +54,17 @@ rec {
|
||||
}) (lib.filterAttrs (name: type: (type == "regular") && (lib.hasSuffix ".age" name) ) (if builtins.pathExists secretsPath then builtins.readDir secretsPath else {}));
|
||||
})
|
||||
# Automatically load secrets from sops file for host
|
||||
({ ... }: {
|
||||
({ config, lib, ... }: {
|
||||
sops.defaultSopsFile = ../hosts + "/${name}/secrets.json";
|
||||
sops.secrets = let
|
||||
secretFile = config.sops.defaultSopsFile;
|
||||
secretNames = builtins.filter (name: name != "sops") (builtins.attrNames (builtins.fromJSON (builtins.readFile secretFile)));
|
||||
secrets = if builtins.pathExists secretFile then
|
||||
lib.listToAttrs (builtins.map (name: lib.nameValuePair name {}) secretNames)
|
||||
else
|
||||
{};
|
||||
in
|
||||
secrets;
|
||||
})
|
||||
];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user