Skip to content

Commit

Permalink
Merge pull request #14000 from nbp/fix-extend
Browse files Browse the repository at this point in the history
Use fix and extends functions for all-packages.nix
  • Loading branch information
nbp committed Mar 24, 2016
2 parents 99c4f14 + 87ad35e commit 5d6a4a6
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 194 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.

else

import ./pkgs/top-level/all-packages.nix
import ./pkgs/top-level
4 changes: 2 additions & 2 deletions pkgs/build-support/dotnetbuildhelpers/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ helperFunctions, mono, pkgconfig }:
helperFunctions.runCommand
{ runCommand, mono, pkgconfig }:
runCommand
"dotnetbuildhelpers"
{ preferLocalBuild = true; }
''
Expand Down
15 changes: 13 additions & 2 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
215 changes: 26 additions & 189 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 ./../..) {
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -303,9 +151,7 @@ let
dotnetfx = dotnetfx40;
};

dotnetbuildhelpers = callPackage ../build-support/dotnetbuildhelpers {
inherit helperFunctions;
};
dotnetbuildhelpers = callPackage ../build-support/dotnetbuildhelpers { };

dispad = callPackage ../tools/X11/dispad { };

Expand Down Expand Up @@ -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
Loading

0 comments on commit 5d6a4a6

Please sign in to comment.