diff options
Diffstat (limited to 'pkgs/top-level')
-rw-r--r-- | pkgs/top-level/default.nix | 5 | ||||
-rw-r--r-- | pkgs/top-level/impure.nix | 19 | ||||
-rw-r--r-- | pkgs/top-level/stage.nix | 26 |
3 files changed, 30 insertions, 20 deletions
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 04daf9778ff..a146dad63bc 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -23,6 +23,9 @@ , # Allow a configuration attribute set to be passed in as an argument. config ? {} +, # List of overlays layers used to extend Nixpkgs. + overlays ? [] + , # A function booting the final package set for a specific standard # environment. See below for the arguments given to that function, # the type of list it returns. @@ -80,7 +83,7 @@ in let boot = import ../stdenv/booter.nix { inherit lib allPackages; }; stages = stdenvStages { - inherit lib system platform crossSystem config; + inherit lib system platform crossSystem config overlays; }; pkgs = boot stages; diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix index e9066815927..1aa55f7293b 100644 --- a/pkgs/top-level/impure.nix +++ b/pkgs/top-level/impure.nix @@ -18,7 +18,24 @@ else if homeDir != "" && pathExists configFile2 then import configFile2 else {} +, # Overlays are used to extend Nixpkgs collection with additional + # collections of packages. These collection of packages are part of the + # fix-point made by Nixpkgs. + overlays ? let + inherit (builtins) getEnv pathExists readDir attrNames map sort + lessThan; + dirEnv = getEnv "NIXPKGS_OVERLAYS"; + dirHome = (getEnv "HOME") + "/.nixpkgs/overlays"; + dirCheck = dir: dir != "" && pathExists (dir + "/."); + overlays = dir: + let content = readDir dir; in + map (n: import "${dir}/${n}") (sort lessThan (attrNames content)); + in + if dirCheck dirEnv then overlays dirEnv + else if dirCheck dirHome then overlays dirHome + else [] + , ... } @ args: -import ./. (args // { inherit system config; }) +import ./. (args // { inherit system config overlays; }) diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index ebc6473e425..cbf65870eb7 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -30,6 +30,8 @@ , # The configuration attribute set config +, overlays # List of overlays to use in the fix-point. + , crossSystem , platform , lib @@ -79,7 +81,7 @@ let ((config.packageOverrides or (super: {})) super); # The complete chain of package set builders, applied from top to bottom - toFix = lib.foldl' (lib.flip lib.extends) (self: {}) [ + toFix = lib.foldl' (lib.flip lib.extends) (self: {}) ([ stdenvBootstappingAndPlatforms stdenvAdapters trivialBuilders @@ -87,20 +89,8 @@ let aliases stdenvOverrides configOverrides - ]; - - # Use `overridePackages` to easily override this package set. - # Warning: this function is very expensive and must not be used - # from within the nixpkgs repository. - # - # Example: - # pkgs.overridePackages (self: super: { - # foo = super.foo.override { ... }; - # } - # - # The result is `pkgs' where all the derivations depending on `foo' - # will use the new version. - - # Return the complete set of packages. Warning: this function is very - # expensive! -in lib.makeExtensibleWithCustomName "overridePackages" toFix + ] ++ overlays); + +in + # Return the complete set of packages. + lib.fix toFix |