2023-09-13 21:16:56 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2023-08-28 09:09:05 +00:00
|
|
|
{
|
2023-09-06 14:08:36 +00:00
|
|
|
options.clanCore.secretStore = lib.mkOption {
|
|
|
|
type = lib.types.enum [ "sops" "password-store" "custom" ];
|
|
|
|
default = "sops";
|
|
|
|
description = ''
|
|
|
|
method to store secrets
|
2023-09-14 12:15:51 +00:00
|
|
|
custom can be used to define a custom secret store.
|
|
|
|
one would have to define system.clan.generateSecrets and system.clan.uploadSecrets
|
2023-09-06 14:08:36 +00:00
|
|
|
'';
|
|
|
|
};
|
2023-08-30 13:24:33 +00:00
|
|
|
options.clanCore.secrets = lib.mkOption {
|
2023-09-13 21:16:56 +00:00
|
|
|
default = { };
|
2023-08-28 09:09:05 +00:00
|
|
|
type = lib.types.attrsOf
|
|
|
|
(lib.types.submodule (secret: {
|
|
|
|
options = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
default = secret.config._module.args.name;
|
|
|
|
description = ''
|
|
|
|
namespace of the secret
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
generator = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
|
|
|
description = ''
|
|
|
|
script to generate the secret.
|
|
|
|
can be set to null. then the user has to provide the secret via the clan cli
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
secrets = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf (lib.types.submodule (secret: {
|
|
|
|
options = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
name of the secret
|
|
|
|
'';
|
|
|
|
default = secret.config._module.args.name;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
description = ''
|
|
|
|
path where the secret is located in the filesystem
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
facts = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf (lib.types.submodule (fact: {
|
|
|
|
options = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
name of the fact
|
|
|
|
'';
|
|
|
|
default = fact.config._module.args.name;
|
|
|
|
};
|
|
|
|
path = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
path to a fact which is generated by the generator
|
|
|
|
'';
|
2023-09-14 13:22:13 +00:00
|
|
|
default = "machines/${config.clanCore.machineName}/facts/${fact.config._module.args.name}";
|
2023-08-28 09:09:05 +00:00
|
|
|
};
|
|
|
|
value = lib.mkOption {
|
2023-09-14 13:22:13 +00:00
|
|
|
default = builtins.readFile "${config.clanCore.clanDir}/fact.config.path";
|
2023-08-28 09:09:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
2023-09-14 11:49:20 +00:00
|
|
|
config.system.build.generateUploadSecrets = pkgs.writeScript "generate_upload_secrets" ''
|
|
|
|
${config.system.clan.generateSecrets}
|
|
|
|
${config.system.clan.uploadSecrets}
|
2023-09-13 21:16:56 +00:00
|
|
|
'';
|
2023-08-28 09:09:05 +00:00
|
|
|
imports = [
|
2023-09-06 14:09:43 +00:00
|
|
|
./sops.nix
|
|
|
|
./password-store.nix
|
2023-08-28 09:09:05 +00:00
|
|
|
];
|
|
|
|
}
|