mirror of
https://github.com/numtide/flake-utils.git
synced 2025-03-16 13:28:22 +00:00
fixup! introduce externally extensible systems (#93)
re-expose defaultSystems even if it doesn't make a lot of sense anymore, to not break back-compat.
This commit is contained in:
parent
1c226cc8c6
commit
471aed544a
2 changed files with 16 additions and 18 deletions
11
README.md
11
README.md
|
@ -1,7 +1,5 @@
|
||||||
# flake-utils
|
# flake-utils
|
||||||
|
|
||||||
[](https://matrix.to/#/#flake-utils:numtide.com)
|
|
||||||
|
|
||||||
**STATUS: stable**
|
**STATUS: stable**
|
||||||
|
|
||||||
Pure Nix flake utility functions.
|
Pure Nix flake utility functions.
|
||||||
|
@ -32,14 +30,11 @@ Eg: instead of typing `"x86_64-linux"`, use `system.x86_64-linux`.
|
||||||
|
|
||||||
A list of all systems defined in nixpkgs. For a smaller list see `defaultSystems`.
|
A list of all systems defined in nixpkgs. For a smaller list see `defaultSystems`.
|
||||||
|
|
||||||
### `defaultSystems :: [<system>]`
|
### `defaultSystems :: [<system>]` (deprecated)
|
||||||
|
|
||||||
The list of systems supported by nixpkgs and built by hydra.
|
The list of systems passed to the flake-utils `systems` input.
|
||||||
Useful if you want add additional platforms:
|
|
||||||
|
|
||||||
```nix
|
Use this pattern to pass different systems to your flake: <https://github.com/nix-systems/nix-systems>.
|
||||||
eachSystem (defaultSystems ++ [system.armv7l-linux]) (system: { hello = 42; })
|
|
||||||
```
|
|
||||||
|
|
||||||
### `eachSystem :: [<system>] -> (<system> -> attrs)`
|
### `eachSystem :: [<system>] -> (<system> -> attrs)`
|
||||||
|
|
||||||
|
|
23
lib.nix
23
lib.nix
|
@ -8,6 +8,8 @@
|
||||||
]
|
]
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
inherit defaultSystems;
|
||||||
|
|
||||||
# List of all systems defined in nixpkgs
|
# List of all systems defined in nixpkgs
|
||||||
# Keep in sync with nixpkgs wit the following command:
|
# Keep in sync with nixpkgs wit the following command:
|
||||||
# $ nix-instantiate --json --eval --expr "with import <nixpkgs> {}; lib.platforms.all" | jq 'sort' | sed 's!,!!'
|
# $ nix-instantiate --json --eval --expr "with import <nixpkgs> {}; lib.platforms.all" | jq 'sort' | sed 's!,!!'
|
||||||
|
@ -119,8 +121,8 @@ let
|
||||||
builtins.mapAttrs
|
builtins.mapAttrs
|
||||||
(name: value:
|
(name: value:
|
||||||
if ! (builtins.isAttrs value) then value
|
if ! (builtins.isAttrs value) then value
|
||||||
else if isDerivation value then (merged.${name} or {}) // { ${system} = value; }
|
else if isDerivation value then (merged.${name} or { }) // { ${system} = value; }
|
||||||
else pushDownSystem system (merged.${name} or {}) value);
|
else pushDownSystem system (merged.${name} or { }) value);
|
||||||
|
|
||||||
# Merge together the outputs for all systems.
|
# Merge together the outputs for all systems.
|
||||||
op = attrs: system:
|
op = attrs: system:
|
||||||
|
@ -130,13 +132,14 @@ let
|
||||||
let
|
let
|
||||||
appendSystem = key: system: ret:
|
appendSystem = key: system: ret:
|
||||||
if key == "hydraJobs"
|
if key == "hydraJobs"
|
||||||
then (pushDownSystem system (attrs.hydraJobs or {}) ret.hydraJobs)
|
then (pushDownSystem system (attrs.hydraJobs or { }) ret.hydraJobs)
|
||||||
else { ${system} = ret.${key}; };
|
else { ${system} = ret.${key}; };
|
||||||
in attrs //
|
in
|
||||||
{
|
attrs //
|
||||||
${key} = (attrs.${key} or { })
|
{
|
||||||
// (appendSystem key system ret);
|
${key} = (attrs.${key} or { })
|
||||||
}
|
// (appendSystem key system ret);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
builtins.foldl' op attrs (builtins.attrNames ret);
|
builtins.foldl' op attrs (builtins.attrNames ret);
|
||||||
|
@ -146,7 +149,7 @@ let
|
||||||
|
|
||||||
# eachSystemMap using defaultSystems
|
# eachSystemMap using defaultSystems
|
||||||
eachDefaultSystemMap = eachSystemMap defaultSystems;
|
eachDefaultSystemMap = eachSystemMap defaultSystems;
|
||||||
|
|
||||||
# Builds a map from <attr>=value to <system>.<attr> = value.
|
# Builds a map from <attr>=value to <system>.<attr> = value.
|
||||||
eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);
|
eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue