secrets: fix build when host has no secrets
This commit is contained in:
@@ -28,21 +28,26 @@
|
|||||||
{ config, lib, sane-lib, ... }:
|
{ config, lib, sane-lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib.strings) hasSuffix removeSuffix;
|
|
||||||
secretsForHost = host: let
|
secretsForHost = host: let
|
||||||
extraAttrsForPath = path: lib.optionalAttrs (sane-lib.path.isChild "guest" path && builtins.hasAttr "guest" config.users.users) {
|
extraAttrsForPath = path: lib.optionalAttrs (sane-lib.path.isChild "guest" path && builtins.hasAttr "guest" config.users.users) {
|
||||||
owner = "guest";
|
owner = "guest";
|
||||||
};
|
};
|
||||||
|
secretsInSrc = (
|
||||||
|
if builtins.pathExists ../../secrets/${host} then
|
||||||
|
sane-lib.enumerateFilePaths ../../secrets/${host}
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
);
|
||||||
in sane-lib.joinAttrsets (
|
in sane-lib.joinAttrsets (
|
||||||
map
|
map
|
||||||
(path: lib.optionalAttrs (hasSuffix ".bin" path) (sane-lib.nameValueToAttrs {
|
(path: lib.optionalAttrs (lib.hasSuffix ".bin" path) (sane-lib.nameValueToAttrs {
|
||||||
name = removeSuffix ".bin" path;
|
name = lib.removeSuffix ".bin" path;
|
||||||
value = {
|
value = {
|
||||||
sopsFile = ../../secrets/${host}/${path};
|
sopsFile = ../../secrets/${host}/${path};
|
||||||
format = "binary";
|
format = "binary";
|
||||||
} // (extraAttrsForPath path);
|
} // (extraAttrsForPath path);
|
||||||
}))
|
}))
|
||||||
(sane-lib.enumerateFilePaths ../../secrets/${host})
|
secretsInSrc
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user