mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 16:21: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,26 +7,32 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.custom.sops;
|
||||
|
||||
absoluteSecretsPath = "${self}/" + cfg.secretsFile;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.sops-nix.nixosModules.sops ];
|
||||
|
||||
options.custom.sops = {
|
||||
enable = lib.mkEnableOption "";
|
||||
defaultSopsFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "${self}/hosts/${config.networking.hostName}/secrets.json";
|
||||
agePublicKey = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
secretsFile = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "hosts/${config.networking.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 = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||
inherit (cfg) defaultSopsFile;
|
||||
defaultSopsFile = absoluteSecretsPath;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue