mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
Merge pull request #14000 from nbp/fix-extend
Use fix and extends functions for all-packages.nix
This commit is contained in:
commit
5d6a4a6fa9
@ -6,4 +6,4 @@ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.
|
||||
|
||||
else
|
||||
|
||||
import ./pkgs/top-level/all-packages.nix
|
||||
import ./pkgs/top-level
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ helperFunctions, mono, pkgconfig }:
|
||||
helperFunctions.runCommand
|
||||
{ runCommand, mono, pkgconfig }:
|
||||
runCommand
|
||||
"dotnetbuildhelpers"
|
||||
{ preferLocalBuild = true; }
|
||||
''
|
||||
|
@ -2,9 +2,21 @@ self:
|
||||
|
||||
with self;
|
||||
|
||||
let
|
||||
# Removing recurseForDerivation prevents derivations of aliased attribute
|
||||
# set to appear while listing all the packages available.
|
||||
removeRecurseForDerivations = _n: alias: with lib;
|
||||
if alias.recurseForDerivations or false then
|
||||
removeAttrs alias ["recurseForDerivations"]
|
||||
else alias;
|
||||
|
||||
doNotDisplayTwice = aliases:
|
||||
lib.mapAttrs removeRecurseForDerivations aliases;
|
||||
in
|
||||
|
||||
### Deprecated aliases - for backward compatibility
|
||||
|
||||
rec {
|
||||
doNotDisplayTwice rec {
|
||||
accounts-qt = qt5.accounts-qt; # added 2015-12-19
|
||||
adobeReader = adobe-reader;
|
||||
aircrackng = aircrack-ng; # added 2016-01-14
|
||||
@ -50,7 +62,6 @@ rec {
|
||||
mssys = ms-sys; # added 2015-12-13
|
||||
multipath_tools = multipath-tools; # added 2016-01-21
|
||||
mupen64plus1_5 = mupen64plus; # added 2016-02-12
|
||||
ncat = nmap; # added 2016-01-26
|
||||
nfsUtils = nfs-utils; # added 2014-12-06
|
||||
phonon_qt5 = qt5.phonon; # added 2015-12-19
|
||||
phonon_qt5_backend_gstreamer = qt5.phonon-backend-gstreamer; # added 2015-12-19
|
||||
|
@ -1,133 +1,16 @@
|
||||
/* This file composes the Nix Packages collection. That is, it
|
||||
imports the functions that build the various packages, and calls
|
||||
them with appropriate arguments. The result is a set of all the
|
||||
packages in the Nix Packages collection for some particular
|
||||
platform. */
|
||||
{ system, bootStdenv, noSysDirs, gccWithCC, gccWithProfiling
|
||||
, config, crossSystem, platform, lib
|
||||
, pkgsWithOverrides
|
||||
, ... }:
|
||||
self: pkgs:
|
||||
|
||||
|
||||
{ # The system (e.g., `i686-linux') for which to build the packages.
|
||||
system ? builtins.currentSystem
|
||||
|
||||
, # The standard environment to use. Only used for bootstrapping. If
|
||||
# null, the default standard environment is used.
|
||||
bootStdenv ? null
|
||||
|
||||
, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
|
||||
# outside of the store. Thus, GCC, GFortran, & co. must always look for
|
||||
# files in standard system directories (/usr/include, etc.)
|
||||
noSysDirs ? (system != "x86_64-freebsd" && system != "i686-freebsd"
|
||||
&& system != "x86_64-solaris"
|
||||
&& system != "x86_64-kfreebsd-gnu")
|
||||
|
||||
# More flags for the bootstrapping of stdenv.
|
||||
, gccWithCC ? true
|
||||
, gccWithProfiling ? true
|
||||
|
||||
, # Allow a configuration attribute set to be passed in as an
|
||||
# argument. Otherwise, it's read from $NIXPKGS_CONFIG or
|
||||
# ~/.nixpkgs/config.nix.
|
||||
config ? null
|
||||
|
||||
, crossSystem ? null
|
||||
, platform ? null
|
||||
}:
|
||||
|
||||
|
||||
let config_ = config; platform_ = platform; in # rename the function arguments
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
defaultScope = pkgs // pkgs.xorg;
|
||||
in
|
||||
|
||||
lib = import ../../lib;
|
||||
|
||||
# The contents of the configuration file found at $NIXPKGS_CONFIG or
|
||||
# $HOME/.nixpkgs/config.nix.
|
||||
# for NIXOS (nixos-rebuild): use nixpkgs.config option
|
||||
config =
|
||||
let
|
||||
toPath = builtins.toPath;
|
||||
getEnv = x: if builtins ? getEnv then builtins.getEnv x else "";
|
||||
pathExists = name:
|
||||
builtins ? pathExists && builtins.pathExists (toPath name);
|
||||
|
||||
configFile = getEnv "NIXPKGS_CONFIG";
|
||||
homeDir = getEnv "HOME";
|
||||
configFile2 = homeDir + "/.nixpkgs/config.nix";
|
||||
|
||||
configExpr =
|
||||
if config_ != null then config_
|
||||
else if configFile != "" && pathExists configFile then import (toPath configFile)
|
||||
else if homeDir != "" && pathExists configFile2 then import (toPath configFile2)
|
||||
else {};
|
||||
|
||||
in
|
||||
# allow both:
|
||||
# { /* the config */ } and
|
||||
# { pkgs, ... } : { /* the config */ }
|
||||
if builtins.isFunction configExpr
|
||||
then configExpr { inherit pkgs; }
|
||||
else configExpr;
|
||||
|
||||
# Allow setting the platform in the config file. Otherwise, let's use a reasonable default (pc)
|
||||
|
||||
platformAuto = let
|
||||
platforms = (import ./platforms.nix);
|
||||
in
|
||||
if system == "armv6l-linux" then platforms.raspberrypi
|
||||
else if system == "armv7l-linux" then platforms.armv7l-hf-multiplatform
|
||||
else if system == "armv5tel-linux" then platforms.sheevaplug
|
||||
else if system == "mips64el-linux" then platforms.fuloong2f_n32
|
||||
else if system == "x86_64-linux" then platforms.pc64
|
||||
else if system == "i686-linux" then platforms.pc32
|
||||
else platforms.pcBase;
|
||||
|
||||
platform = if platform_ != null then platform_
|
||||
else config.platform or platformAuto;
|
||||
|
||||
# Helper functions that are exported through `pkgs'.
|
||||
helperFunctions =
|
||||
stdenvAdapters //
|
||||
(import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; });
|
||||
|
||||
stdenvAdapters =
|
||||
import ../stdenv/adapters.nix pkgs;
|
||||
|
||||
|
||||
# Allow packages to be overriden globally via the `packageOverrides'
|
||||
# configuration option, which must be a function that takes `pkgs'
|
||||
# as an argument and returns a set of new or overriden packages.
|
||||
# The `packageOverrides' function is called with the *original*
|
||||
# (un-overriden) set of packages, allowing packageOverrides
|
||||
# attributes to refer to the original attributes (e.g. "foo =
|
||||
# ... pkgs.foo ...").
|
||||
pkgs = applyGlobalOverrides (config.packageOverrides or (pkgs: {}));
|
||||
|
||||
mkOverrides = pkgsOrig: overrides: overrides //
|
||||
(lib.optionalAttrs (pkgsOrig.stdenv ? overrides && crossSystem == null) (pkgsOrig.stdenv.overrides pkgsOrig));
|
||||
|
||||
# Return the complete set of packages, after applying the overrides
|
||||
# returned by the `overrider' function (see above). Warning: this
|
||||
# function is very expensive!
|
||||
applyGlobalOverrides = overrider:
|
||||
let
|
||||
# Call the overrider function. We don't want stdenv overrides
|
||||
# in the case of cross-building, or otherwise the basic
|
||||
# overrided packages will not be built with the crossStdenv
|
||||
# adapter.
|
||||
overrides = mkOverrides pkgsOrig (overrider pkgsOrig);
|
||||
|
||||
# The un-overriden packages, passed to `overrider'.
|
||||
pkgsOrig = pkgsFun pkgs {};
|
||||
|
||||
# The overriden, final packages.
|
||||
pkgs = pkgsFun pkgs overrides;
|
||||
in pkgs;
|
||||
|
||||
|
||||
# The package compositions. Yes, this isn't properly indented.
|
||||
pkgsFun = pkgs: overrides:
|
||||
with helperFunctions;
|
||||
let defaultScope = pkgs // pkgs.xorg; self = self_ // overrides;
|
||||
self_ = with self; helperFunctions // {
|
||||
{
|
||||
|
||||
# Make some arguments passed to all-packages.nix available
|
||||
inherit system platform;
|
||||
@ -157,11 +40,7 @@ let
|
||||
#
|
||||
# The result is `pkgs' where all the derivations depending on `foo'
|
||||
# will use the new version.
|
||||
overridePackages = f:
|
||||
let
|
||||
newpkgs = pkgsFun newpkgs overrides;
|
||||
overrides = mkOverrides pkgs (f newpkgs pkgs);
|
||||
in newpkgs;
|
||||
overridePackages = f: pkgsWithOverrides f;
|
||||
|
||||
# Override system. This is useful to build i686 packages on x86_64-linux.
|
||||
forceSystem = system: kernel: (import ./../..) {
|
||||
@ -171,19 +50,31 @@ let
|
||||
crossSystem;
|
||||
};
|
||||
|
||||
|
||||
# Used by wine, firefox with debugging version of Flash, ...
|
||||
pkgsi686Linux = forceSystem "i686-linux" "i386";
|
||||
|
||||
callPackage_i686 = lib.callPackageWith (pkgsi686Linux // pkgsi686Linux.xorg);
|
||||
|
||||
forceNativeDrv = drv : if crossSystem == null then drv else
|
||||
(drv // { crossDrv = drv.nativeDrv; });
|
||||
|
||||
stdenvCross = lowPrio (makeStdenvCross defaultStdenv crossSystem binutilsCross gccCrossStageFinal);
|
||||
|
||||
# A stdenv capable of building 32-bit binaries. On x86_64-linux,
|
||||
# it uses GCC compiled with multilib support; on i686-linux, it's
|
||||
# just the plain stdenv.
|
||||
stdenv_32bit = lowPrio (
|
||||
if system == "x86_64-linux" then
|
||||
overrideCC stdenv gcc_multi
|
||||
else
|
||||
stdenv);
|
||||
|
||||
# For convenience, allow callers to get the path to Nixpkgs.
|
||||
path = ../..;
|
||||
|
||||
|
||||
### Helper functions.
|
||||
inherit lib config stdenvAdapters;
|
||||
inherit lib config;
|
||||
|
||||
inherit (lib) lowPrio hiPrio appendToName makeOverridable;
|
||||
inherit (misc) versionedDerivation;
|
||||
@ -206,49 +97,6 @@ let
|
||||
nixpkgs-lint = callPackage ../../maintainers/scripts/nixpkgs-lint.nix { };
|
||||
|
||||
|
||||
### STANDARD ENVIRONMENT
|
||||
|
||||
|
||||
allStdenvs = import ../stdenv {
|
||||
inherit system platform config lib;
|
||||
allPackages = args: import ./../.. ({ inherit config system; } // args);
|
||||
};
|
||||
|
||||
defaultStdenv = allStdenvs.stdenv // { inherit platform; };
|
||||
|
||||
stdenvCross = lowPrio (makeStdenvCross defaultStdenv crossSystem binutilsCross gccCrossStageFinal);
|
||||
|
||||
stdenv =
|
||||
if bootStdenv != null then (bootStdenv // {inherit platform;}) else
|
||||
if crossSystem != null then
|
||||
stdenvCross
|
||||
else
|
||||
let
|
||||
changer = config.replaceStdenv or null;
|
||||
in if changer != null then
|
||||
changer {
|
||||
# We import again all-packages to avoid recursivities.
|
||||
pkgs = import ./../.. {
|
||||
# We remove packageOverrides to avoid recursivities
|
||||
config = removeAttrs config [ "replaceStdenv" ];
|
||||
};
|
||||
}
|
||||
else
|
||||
defaultStdenv;
|
||||
|
||||
forceNativeDrv = drv : if crossSystem == null then drv else
|
||||
(drv // { crossDrv = drv.nativeDrv; });
|
||||
|
||||
# A stdenv capable of building 32-bit binaries. On x86_64-linux,
|
||||
# it uses GCC compiled with multilib support; on i686-linux, it's
|
||||
# just the plain stdenv.
|
||||
stdenv_32bit = lowPrio (
|
||||
if system == "x86_64-linux" then
|
||||
overrideCC stdenv gcc_multi
|
||||
else
|
||||
stdenv);
|
||||
|
||||
|
||||
### BUILD SUPPORT
|
||||
|
||||
attrSetToDir = arg: callPackage ../build-support/upstream-updater/attrset-to-dir.nix {
|
||||
@ -303,9 +151,7 @@ let
|
||||
dotnetfx = dotnetfx40;
|
||||
};
|
||||
|
||||
dotnetbuildhelpers = callPackage ../build-support/dotnetbuildhelpers {
|
||||
inherit helperFunctions;
|
||||
};
|
||||
dotnetbuildhelpers = callPackage ../build-support/dotnetbuildhelpers { };
|
||||
|
||||
dispad = callPackage ../tools/X11/dispad { };
|
||||
|
||||
@ -16482,14 +16328,5 @@ let
|
||||
|
||||
mg = callPackage ../applications/editors/mg { };
|
||||
|
||||
}; # self_ =
|
||||
}
|
||||
|
||||
|
||||
aliases = import ./aliases.nix self;
|
||||
|
||||
tweakAlias = _n: alias: with lib;
|
||||
if alias.recurseForDerivations or false then
|
||||
removeAttrs alias ["recurseForDerivations"]
|
||||
else alias;
|
||||
|
||||
in lib.mapAttrs tweakAlias aliases // self; in pkgs
|
||||
|
148
pkgs/top-level/default.nix
Normal file
148
pkgs/top-level/default.nix
Normal file
@ -0,0 +1,148 @@
|
||||
/* This file composes the Nix Packages collection. That is, it
|
||||
imports the functions that build the various packages, and calls
|
||||
them with appropriate arguments. The result is a set of all the
|
||||
packages in the Nix Packages collection for some particular
|
||||
platform. */
|
||||
|
||||
|
||||
{ # The system (e.g., `i686-linux') for which to build the packages.
|
||||
system ? builtins.currentSystem
|
||||
|
||||
, # The standard environment to use. Only used for bootstrapping. If
|
||||
# null, the default standard environment is used.
|
||||
bootStdenv ? null
|
||||
|
||||
, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
|
||||
# outside of the store. Thus, GCC, GFortran, & co. must always look for
|
||||
# files in standard system directories (/usr/include, etc.)
|
||||
noSysDirs ? (system != "x86_64-freebsd" && system != "i686-freebsd"
|
||||
&& system != "x86_64-solaris"
|
||||
&& system != "x86_64-kfreebsd-gnu")
|
||||
|
||||
# More flags for the bootstrapping of stdenv.
|
||||
, gccWithCC ? true
|
||||
, gccWithProfiling ? true
|
||||
|
||||
, # Allow a configuration attribute set to be passed in as an
|
||||
# argument. Otherwise, it's read from $NIXPKGS_CONFIG or
|
||||
# ~/.nixpkgs/config.nix.
|
||||
config ? null
|
||||
|
||||
, crossSystem ? null
|
||||
, platform ? null
|
||||
}:
|
||||
|
||||
|
||||
let config_ = config; platform_ = platform; in # rename the function arguments
|
||||
|
||||
let
|
||||
|
||||
lib = import ../../lib;
|
||||
|
||||
# The contents of the configuration file found at $NIXPKGS_CONFIG or
|
||||
# $HOME/.nixpkgs/config.nix.
|
||||
# for NIXOS (nixos-rebuild): use nixpkgs.config option
|
||||
config =
|
||||
let
|
||||
toPath = builtins.toPath;
|
||||
getEnv = x: if builtins ? getEnv then builtins.getEnv x else "";
|
||||
pathExists = name:
|
||||
builtins ? pathExists && builtins.pathExists (toPath name);
|
||||
|
||||
configFile = getEnv "NIXPKGS_CONFIG";
|
||||
homeDir = getEnv "HOME";
|
||||
configFile2 = homeDir + "/.nixpkgs/config.nix";
|
||||
|
||||
configExpr =
|
||||
if config_ != null then config_
|
||||
else if configFile != "" && pathExists configFile then import (toPath configFile)
|
||||
else if homeDir != "" && pathExists configFile2 then import (toPath configFile2)
|
||||
else {};
|
||||
|
||||
in
|
||||
# allow both:
|
||||
# { /* the config */ } and
|
||||
# { pkgs, ... } : { /* the config */ }
|
||||
if builtins.isFunction configExpr
|
||||
then configExpr { inherit pkgs; }
|
||||
else configExpr;
|
||||
|
||||
# Allow setting the platform in the config file. Otherwise, let's use a reasonable default (pc)
|
||||
|
||||
platformAuto = let
|
||||
platforms = (import ./platforms.nix);
|
||||
in
|
||||
if system == "armv6l-linux" then platforms.raspberrypi
|
||||
else if system == "armv7l-linux" then platforms.armv7l-hf-multiplatform
|
||||
else if system == "armv5tel-linux" then platforms.sheevaplug
|
||||
else if system == "mips64el-linux" then platforms.fuloong2f_n32
|
||||
else if system == "x86_64-linux" then platforms.pc64
|
||||
else if system == "i686-linux" then platforms.pc32
|
||||
else platforms.pcBase;
|
||||
|
||||
platform = if platform_ != null then platform_
|
||||
else config.platform or platformAuto;
|
||||
|
||||
topLevelArguments = {
|
||||
inherit system bootStdenv noSysDirs gccWithCC gccWithProfiling config
|
||||
crossSystem platform lib;
|
||||
};
|
||||
|
||||
# Allow packages to be overridden globally via the `packageOverrides'
|
||||
# configuration option, which must be a function that takes `pkgs'
|
||||
# as an argument and returns a set of new or overridden packages.
|
||||
# The `packageOverrides' function is called with the *original*
|
||||
# (un-overridden) set of packages, allowing packageOverrides
|
||||
# attributes to refer to the original attributes (e.g. "foo =
|
||||
# ... pkgs.foo ...").
|
||||
pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {}));
|
||||
|
||||
# Return the complete set of packages, after applying the overrides
|
||||
# returned by the `overrider' function (see above). Warning: this
|
||||
# function is very expensive!
|
||||
pkgsWithOverrides = overrider:
|
||||
let
|
||||
stdenvAdapters = self: super:
|
||||
let res = import ../stdenv/adapters.nix self; in res // {
|
||||
stdenvAdapters = res;
|
||||
};
|
||||
|
||||
trivialBuilders = self: super:
|
||||
(import ../build-support/trivial-builders.nix {
|
||||
inherit lib; inherit (self) stdenv; inherit (self.xorg) lndir;
|
||||
});
|
||||
|
||||
stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs;
|
||||
|
||||
allPackagesArgs = topLevelArguments // { inherit pkgsWithOverrides; };
|
||||
allPackages = self: super:
|
||||
let res = import ./all-packages.nix allPackagesArgs res self;
|
||||
in res;
|
||||
|
||||
aliases = self: super: import ./aliases.nix super;
|
||||
|
||||
# stdenvOverrides is used to avoid circular dependencies for building
|
||||
# the standard build environment. This mechanism uses the override
|
||||
# mechanism to implement some staged compilation of the stdenv.
|
||||
#
|
||||
# We don't want stdenv overrides in the case of cross-building, or
|
||||
# otherwise the basic overridden packages will not be built with the
|
||||
# crossStdenv adapter.
|
||||
stdenvOverrides = self: super:
|
||||
lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides)
|
||||
(super.stdenv.overrides super);
|
||||
|
||||
customOverrides = self: super:
|
||||
lib.optionalAttrs (bootStdenv == null) (overrider self super);
|
||||
in
|
||||
lib.fix' (
|
||||
lib.extends customOverrides (
|
||||
lib.extends stdenvOverrides (
|
||||
lib.extends aliases (
|
||||
lib.extends allPackages (
|
||||
lib.extends stdenvDefault (
|
||||
lib.extends trivialBuilders (
|
||||
lib.extends stdenvAdapters (
|
||||
self: {}))))))));
|
||||
in
|
||||
pkgs
|
31
pkgs/top-level/stdenv.nix
Normal file
31
pkgs/top-level/stdenv.nix
Normal file
@ -0,0 +1,31 @@
|
||||
{ system, bootStdenv, crossSystem, config, platform, lib, ... }:
|
||||
self: super:
|
||||
|
||||
with super;
|
||||
|
||||
rec {
|
||||
allStdenvs = import ../stdenv {
|
||||
inherit system platform config lib;
|
||||
allPackages = args: import ./../.. ({ inherit config system; } // args);
|
||||
};
|
||||
|
||||
defaultStdenv = allStdenvs.stdenv // { inherit platform; };
|
||||
|
||||
stdenv =
|
||||
if bootStdenv != null then (bootStdenv // {inherit platform;}) else
|
||||
if crossSystem != null then
|
||||
stdenvCross
|
||||
else
|
||||
let
|
||||
changer = config.replaceStdenv or null;
|
||||
in if changer != null then
|
||||
changer {
|
||||
# We import again all-packages to avoid recursivities.
|
||||
pkgs = import ./../.. {
|
||||
# We remove packageOverrides to avoid recursivities
|
||||
config = removeAttrs config [ "replaceStdenv" ];
|
||||
};
|
||||
}
|
||||
else
|
||||
defaultStdenv;
|
||||
}
|
Loading…
Reference in New Issue
Block a user