Skip to content

Commit

Permalink
fix: mapAttrs' can't deal with null
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Oct 11, 2024
1 parent 4c9a3c5 commit 040b4db
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nix/modules/flake-parts/autowire.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 040b4db

Please sign in to comment.