diff options
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 = { |
