nixfiles/lib/secrets.nix

35 lines
694 B
Nix
Raw Normal View History

2024-01-08 07:49:51 +03:00
{
declare = defs: {
age.secrets = builtins.listToAttrs (
map
(def:
let obj = if builtins.isString def then { name = def; } else def;
in {
name = obj.name;
value = builtins.removeAttrs
(obj // {
file = ../secrets + "/${obj.name}.age";
}) [ "name" ];
}
)
defs
);
};
2024-01-09 08:34:03 +03:00
file = config: name: config.age.secrets.${name}.path;
mount = config: name:
let
path = config.age.secrets.${name}.path;
in
{
path = path;
mounts = {
${path} = {
hostPath = path;
isReadOnly = true;
};
};
};
2024-01-08 07:49:51 +03:00
}