diff --git a/nix/modules/flake-parts/autowire.nix b/nix/modules/flake-parts/autowire.nix index 8d846af..798889a 100644 --- a/nix/modules/flake-parts/autowire.nix +++ b/nix/modules/flake-parts/autowire.nix @@ -2,11 +2,20 @@ { config = let + # Combine mapAttrs' and filterAttrs + # + # f can return null if the attribute should be filtered out. + mapAttrsMaybe = f: attrs: + lib.pipe attrs [ + (lib.mapAttrsToList f) + (builtins.filter (x: x != null)) + builtins.listToAttrs + ]; forAllNixFiles = dir: f: if builtins.pathExists dir then lib.pipe dir [ builtins.readDir - (lib.mapAttrs' (fn: type: + (mapAttrsMaybe (fn: type: if type == "regular" then let name = lib.removeSuffix ".nix" fn; in lib.nameValuePair name (f "${dir}/${fn}")