mirror of
https://gitlab.com/TECHNOFAB/nixlets.git
synced 2025-12-12 01:50:05 +01:00
Merge branch 'feat/secrets' into 'main'
feat: add secrets module See merge request TECHNOFAB/nixlets!2
This commit is contained in:
commit
1052d5f2e5
2 changed files with 40 additions and 0 deletions
|
|
@ -64,6 +64,7 @@ with lib; rec {
|
||||||
helm
|
helm
|
||||||
docker
|
docker
|
||||||
files
|
files
|
||||||
|
./secretsModule.nix
|
||||||
({...}: let
|
({...}: let
|
||||||
finalValues = mkValues "${path}/values.nix" {
|
finalValues = mkValues "${path}/values.nix" {
|
||||||
rawValues = values;
|
rawValues = values;
|
||||||
|
|
@ -94,6 +95,8 @@ with lib; rec {
|
||||||
.config
|
.config
|
||||||
.kubernetes
|
.kubernetes
|
||||||
.resultYAML;
|
.resultYAML;
|
||||||
|
# combines all secrets files in a single directory
|
||||||
|
secrets = args: (eval args).config.kubernetes.secretsCombined;
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchNixlet = url: sha256: mkNixlet (builtins.fetchTarball {inherit url sha256;});
|
fetchNixlet = url: sha256: mkNixlet (builtins.fetchTarball {inherit url sha256;});
|
||||||
|
|
|
||||||
37
lib/secretsModule.nix
Normal file
37
lib/secretsModule.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in {
|
||||||
|
options.kubernetes = {
|
||||||
|
secrets = mkOption {
|
||||||
|
type = types.attrsOf types.path;
|
||||||
|
description = "sops encrypted secrets";
|
||||||
|
example = ''
|
||||||
|
{
|
||||||
|
"abc" = ./some-secret.sops.yaml;
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
secretsCombined = mkOption {
|
||||||
|
internal = true;
|
||||||
|
type = types.package;
|
||||||
|
description = "All sops encrypted secret files in a directory";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config.kubernetes.secretsCombined = let
|
||||||
|
commands = builtins.concatStringsSep "\n" (
|
||||||
|
map (
|
||||||
|
secret: "ln -s ${builtins.getAttr secret config.kubernetes.secrets} $out/${secret}.yaml"
|
||||||
|
)
|
||||||
|
(builtins.attrNames config.kubernetes.secrets)
|
||||||
|
);
|
||||||
|
in
|
||||||
|
pkgs.runCommand "nixlets-secrets-combined" {} ''
|
||||||
|
mkdir -p $out
|
||||||
|
${commands}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue