From dcaba0f0ee01a20061dd31b9bbb72c74c33bb5b5 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 2 Sep 2023 01:34:32 +0000 Subject: [PATCH] secrets: fix build when host has no secrets --- hosts/common/secrets.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hosts/common/secrets.nix b/hosts/common/secrets.nix index ab5bb95b2..379aed1e2 100644 --- a/hosts/common/secrets.nix +++ b/hosts/common/secrets.nix @@ -28,21 +28,26 @@ { config, lib, sane-lib, ... }: let - inherit (lib.strings) hasSuffix removeSuffix; secretsForHost = host: let extraAttrsForPath = path: lib.optionalAttrs (sane-lib.path.isChild "guest" path && builtins.hasAttr "guest" config.users.users) { owner = "guest"; }; + secretsInSrc = ( + if builtins.pathExists ../../secrets/${host} then + sane-lib.enumerateFilePaths ../../secrets/${host} + else + [] + ); in sane-lib.joinAttrsets ( map - (path: lib.optionalAttrs (hasSuffix ".bin" path) (sane-lib.nameValueToAttrs { - name = removeSuffix ".bin" path; + (path: lib.optionalAttrs (lib.hasSuffix ".bin" path) (sane-lib.nameValueToAttrs { + name = lib.removeSuffix ".bin" path; value = { sopsFile = ../../secrets/${host}/${path}; format = "binary"; } // (extraAttrsForPath path); })) - (sane-lib.enumerateFilePaths ../../secrets/${host}) + secretsInSrc ); in {