Skip to content

Commit

Permalink
each{,Default}System: accept binary functions
Browse files Browse the repository at this point in the history
Closes: #78
  • Loading branch information
ilkecan committed Sep 7, 2022
1 parent 628e9f3 commit 19d1236
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ eachSystem allSystems (system: { hello = 42; })
}
```

If you pass a function rather than an attribute set after the `system` argument,
it will receive as its argument the final attribute set. For example:
```nix
eachSystem [ system.x86_64-linux ] (system: self: { a = 2; b = self.a + 3; })
```
`self` is not that useful in this case, as it can be replaced with the `rec`
keyword but there can be situations where it is preferred.

### `eachDefaultSystem -> (<system> -> attrs)`

`eachSystem` pre-populated with `defaultSystems`.
Expand Down
9 changes: 8 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ let
# Merge together the outputs for all systems.
op = attrs: system:
let
ret = f system;
ret =
let
retOrFunc = f system;
in
if builtins.isFunction retOrFunc
then retOrFunc ret
else retOrFunc;

op = attrs: key:
let
appendSystem = key: system: ret:
Expand Down

0 comments on commit 19d1236

Please sign in to comment.