secrets-bao: inline configchanges, remove file, make configChanges attrs
This commit is contained in:
parent
c1f5677520
commit
bd8cff90ed
4 changed files with 269 additions and 257 deletions
|
|
@ -5,13 +5,32 @@
|
|||
|
||||
outputs = { ... }:
|
||||
{
|
||||
lib = {
|
||||
applyConfigChanges = secrets:
|
||||
let
|
||||
substitute = secretPath: value:
|
||||
if builtins.isAttrs value then
|
||||
builtins.mapAttrs (_: v: substitute secretPath v) value
|
||||
else if builtins.isList value then
|
||||
map (v: substitute secretPath v) value
|
||||
else if builtins.isString value then
|
||||
builtins.replaceStrings [ "$SECRET_PATH" ] [ secretPath ] value
|
||||
else
|
||||
value;
|
||||
|
||||
fragments = builtins.attrValues (builtins.mapAttrs (
|
||||
name: s:
|
||||
let
|
||||
secretPath = s.path or ("/run/secrets/" + name);
|
||||
in
|
||||
substitute secretPath (s.configChanges or { })
|
||||
) secrets);
|
||||
in
|
||||
builtins.foldl' (acc: v: acc // v) { } fragments;
|
||||
};
|
||||
|
||||
nixosModules = {
|
||||
default = {
|
||||
imports = [
|
||||
(import ./nixos-module.nix)
|
||||
(import ./nixos-configchanges.nix)
|
||||
];
|
||||
};
|
||||
default = import ./nixos-module.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue