wifi: derive networks from sops secrets file

This commit is contained in:
SebastianStork 2025-07-20 14:47:46 +02:00
parent 2e3b64860f
commit 2da2cd592e
2 changed files with 27 additions and 14 deletions

View file

@ -5,15 +5,28 @@
lib,
...
}:
let
cfg = config.custom.sops;
in
{
imports = [ inputs.sops-nix.nixosModules.sops ];
options.custom.sops.enable = lib.mkEnableOption "";
options.custom.sops = {
enable = lib.mkEnableOption "";
defaultSopsFile = lib.mkOption {
type = lib.types.path;
default = "${self}/hosts/${config.networking.hostName}/secrets.json";
};
secrets = lib.mkOption {
type = lib.types.anything;
default = cfg.defaultSopsFile |> builtins.readFile |> builtins.fromJSON;
};
};
config = lib.mkIf config.custom.sops.enable {
config = lib.mkIf cfg.enable {
sops = {
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
defaultSopsFile = "${self}/hosts/${config.networking.hostName}/secrets.json";
inherit (cfg) defaultSopsFile;
};
};
}