mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 20:39:18 -08:00
Secrets... abstractions
This commit is contained in:
parent
05696b3aea
commit
aecc7fa78d
5 changed files with 40 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ let
|
|||
modules = [
|
||||
tfModule
|
||||
"${toString sources.tf-nix}/modules"
|
||||
./secrets.nix
|
||||
];
|
||||
};
|
||||
in {
|
||||
|
|
|
|||
21
config/modules/meta/secrets.nix
Normal file
21
config/modules/meta/secrets.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = let tf = config; in {
|
||||
variables = mkOption {
|
||||
type = types.attrsOf (types.submodule ({ name, config, ... }: {
|
||||
options.externalSecret = mkEnableOption "Is ths secret to be templated into a command provided?";
|
||||
config = mkIf config.externalSecret {
|
||||
type = "string";
|
||||
value.shellCommand = "${tf.commandPrefix} ${escapeShellArg name}";
|
||||
};
|
||||
}));
|
||||
};
|
||||
commandPrefix = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
./dns.nix
|
||||
./dyndns.nix
|
||||
./yggdrasil.nix
|
||||
./secrets.nix
|
||||
(sources.tf-nix + "/modules/nixos/secrets.nix")
|
||||
(sources.tf-nix + "/modules/nixos/secrets-users.nix")
|
||||
(sources.hexchen + "/modules/network/yggdrasil")
|
||||
|
|
|
|||
15
config/modules/nixos/secrets.nix
Normal file
15
config/modules/nixos/secrets.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.kw = {
|
||||
secrets = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config = mkIf (config.kw.secrets != null) {
|
||||
deploy.tf.variables = genAttrs config.kw.secrets (n: { externalSecret = true; });
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue