diff --git a/README.md b/README.md index 2a54869..2027cfd 100644 --- a/README.md +++ b/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 :: []` +### `defaultSystems :: []` (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: . ### `eachSystem :: [] -> ( -> attrs)` diff --git a/lib.nix b/lib.nix index 17f3569..5490e87 100644 --- a/lib.nix +++ b/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 {}; 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 =value to . = value. eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);