mirror of
https://github.com/numtide/flake-utils.git
synced 2024-12-14 11:47:31 +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
|
||||
|
||||
[![Support room on Matrix](https://img.shields.io/matrix/flake-utils:numtide.com.svg?label=%23flake-utils%3Anumtide.com&logo=matrix&server_fqdn=matrix.numtide.com)](https://matrix.to/#/#flake-utils:numtide.com)
|
||||
|
||||
**STATUS: stable**
|
||||
|
||||
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`.
|
||||
|
||||
### `defaultSystems :: [<system>]`
|
||||
### `defaultSystems :: [<system>]` (deprecated)
|
||||
|
||||
The list of systems supported by nixpkgs and built by hydra.
|
||||
Useful if you want add additional platforms:
|
||||
The list of systems passed to the flake-utils `systems` input.
|
||||
|
||||
```nix
|
||||
eachSystem (defaultSystems ++ [system.armv7l-linux]) (system: { hello = 42; })
|
||||
```
|
||||
Use this pattern to pass different systems to your flake: <https://github.com/nix-systems/nix-systems>.
|
||||
|
||||
### `eachSystem :: [<system>] -> (<system> -> attrs)`
|
||||
|
||||
|
|
23
lib.nix
23
lib.nix
|
@ -8,6 +8,8 @@
|
|||
]
|
||||
}:
|
||||
let
|
||||
inherit defaultSystems;
|
||||
|
||||
# List of all systems defined in nixpkgs
|
||||
# Keep in sync with nixpkgs wit the following command:
|
||||
# $ nix-instantiate --json --eval --expr "with import <nixpkgs> {}; lib.platforms.all" | jq 'sort' | sed 's!,!!'
|
||||
|
@ -119,8 +121,8 @@ let
|
|||
builtins.mapAttrs
|
||||
(name: value:
|
||||
if ! (builtins.isAttrs value) then value
|
||||
else if isDerivation value then (merged.${name} or {}) // { ${system} = value; }
|
||||
else pushDownSystem system (merged.${name} or {}) value);
|
||||
else if isDerivation value then (merged.${name} or { }) // { ${system} = value; }
|
||||
else pushDownSystem system (merged.${name} or { }) value);
|
||||
|
||||
# Merge together the outputs for all systems.
|
||||
op = attrs: system:
|
||||
|
@ -130,13 +132,14 @@ let
|
|||
let
|
||||
appendSystem = key: system: ret:
|
||||
if key == "hydraJobs"
|
||||
then (pushDownSystem system (attrs.hydraJobs or {}) ret.hydraJobs)
|
||||
else { ${system} = ret.${key}; };
|
||||
in attrs //
|
||||
{
|
||||
${key} = (attrs.${key} or { })
|
||||
// (appendSystem key system ret);
|
||||
}
|
||||
then (pushDownSystem system (attrs.hydraJobs or { }) ret.hydraJobs)
|
||||
else { ${system} = ret.${key}; };
|
||||
in
|
||||
attrs //
|
||||
{
|
||||
${key} = (attrs.${key} or { })
|
||||
// (appendSystem key system ret);
|
||||
}
|
||||
;
|
||||
in
|
||||
builtins.foldl' op attrs (builtins.attrNames ret);
|
||||
|
@ -146,7 +149,7 @@ let
|
|||
|
||||
# eachSystemMap using defaultSystems
|
||||
eachDefaultSystemMap = eachSystemMap defaultSystems;
|
||||
|
||||
|
||||
# Builds a map from <attr>=value to <system>.<attr> = value.
|
||||
eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);
|
||||
|
||||
|
|
Loading…
Reference in a new issue