diff options
| author | Miran Bastaja <miran.bastaja04@gmail.com> | 2024-07-30 16:24:22 +0200 |
|---|---|---|
| committer | Miran Bastaja <miran.bastaja04@gmail.com> | 2024-07-30 16:33:16 +0200 |
| commit | a2753d563053fa37f4773e64f652fb54858bf10d (patch) | |
| tree | 648033d11dad92909e6354418b034cb9e1b2ac98 /flake.nix | |
| parent | a524bf5c41c17975d7e85d87db1dc1d49e472f88 (diff) | |
Fix eachSystem
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 67 |
1 files changed, 49 insertions, 18 deletions
@@ -6,30 +6,61 @@ }; outputs = - { - self, - nixpkgs, - systems, - }: + { self, ... }: let - stdenvMinimal = nixpkgs.stdenvNoCC.override { - cc = null; - preHook = ""; - allowedRequsites = null; - initialPath = nixpkgs.lib.filter ( - a: nixpkgs.lib.hasPrefix "coreutils" a.name - ) nixpkgs.stdenvNoCC.initialPath; - extraNativeBuildInputs = [ ]; - }; + systems = (import self.inputs.systems); in { lib = { - # Basically equivalent to flake-utils' eachDefaultSystem - eachSystem = nixpkgs.lib.genAttrs (import systems); + # Equivalent to flake-utils' eachDefaultSystem + # Taken from flake-utils + eachSystem = + f: + let + # Merge together the outptus for all systems + op = + attrs: system: + let + ret = f system; + op = + attrs: key: + attrs + // { + ${key} = (attrs.${key} or { }) // { + ${system} = ret.${key}; + }; + }; + in + builtins.foldl' op attrs (builtins.attrNames ret); + in + builtins.foldl' op { } ( + systems + ++ + # add the current system if --impure is used + ( + if builtins ? currentSystem then + if builtins.elem builtins.currentSystem systems then [ ] else [ builtins.currentSystem ] + else + [ ] + ) + ); # Like mkShell, but with less dependencies. - # See https://fzakaria.com/2021/08/02/a-minimal-nix-shell.html - minimalMkShell = pkgs: pkgs.mkShell.override { stdenv = stdenvMinimal; }; + # Taken from https://fzakaria.com/2021/08/02/a-minimal-nix-shell.html + minimalMkShell = + pkgs: + let + stdenvMinimal = pkgs.stdenvNoCC.override { + cc = null; + preHook = ""; + allowedRequisites = null; + initialPath = pkgs.lib.filter ( + a: pkgs.lib.hasPrefix "coreutils" a.name + ) pkgs.stdenvNoCC.initialPath; + extraNativeBuildInputs = [ ]; + }; + in + pkgs.mkShell.override { stdenv = stdenvMinimal; }; }; templates = { |
