3
0
Fork 0
forked from mirrors/nixpkgs

Random cleanup: use "or" in adapters.nix

This commit is contained in:
Eelco Dolstra 2012-12-28 19:35:35 +01:00
parent 3fa03df78c
commit 22ba03c123

View file

@ -20,7 +20,7 @@ rec {
# for other dependencies. # for other dependencies.
overrideInStdenv = stdenv: pkgs: stdenv // overrideInStdenv = stdenv: pkgs: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // { mkDerivation = args: stdenv.mkDerivation (args //
{ buildInputs = (if args ? buildInputs then args.buildInputs else []) ++ pkgs; } { buildInputs = args.buildInputs or [] ++ pkgs; }
); );
}; };
@ -48,11 +48,11 @@ rec {
# These are added *after* the command-line flags, so we'll # These are added *after* the command-line flags, so we'll
# always optimise for size. # always optimise for size.
NIX_CFLAGS_COMPILE = NIX_CFLAGS_COMPILE =
(if args ? NIX_CFLAGS_COMPILE then args.NIX_CFLAGS_COMPILE else "") args.NIX_CFLAGS_COMPILE or ""
+ " -Os -s -D_BSD_SOURCE=1"; + " -Os -s -D_BSD_SOURCE=1";
configureFlags = configureFlags =
(if args ? configureFlags then args.configureFlags else "") args.configureFlags or ""
+ " --disable-shared"; # brrr... + " --disable-shared"; # brrr...
NIX_GCC = import ../build-support/gcc-wrapper { NIX_GCC = import ../build-support/gcc-wrapper {
@ -75,12 +75,10 @@ rec {
# These are added *after* the command-line flags, so we'll # These are added *after* the command-line flags, so we'll
# always optimise for size. # always optimise for size.
NIX_CFLAGS_COMPILE = NIX_CFLAGS_COMPILE =
(if args ? NIX_CFLAGS_COMPILE then args.NIX_CFLAGS_COMPILE else "") args.NIX_CFLAGS_COMPILE or "" + " -Os -s";
+ " -Os -s";
configureFlags = configureFlags =
(if args ? configureFlags then args.configureFlags else "") args.configureFlags or "" + " --disable-shared"; # brrr...
+ " --disable-shared"; # brrr...
NIX_GCC = runCommand "klibc-wrapper" {} '' NIX_GCC = runCommand "klibc-wrapper" {} ''
mkdir -p $out/bin mkdir -p $out/bin
@ -100,9 +98,8 @@ rec {
makeStaticBinaries = stdenv: stdenv // makeStaticBinaries = stdenv: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // { { mkDerivation = args: stdenv.mkDerivation (args // {
NIX_CFLAGS_LINK = "-static"; NIX_CFLAGS_LINK = "-static";
configureFlags = configureFlags =
(if args ? configureFlags then toString args.configureFlags else "") toString args.configureFlags or ""
+ " --disable-shared"; # brrr... + " --disable-shared"; # brrr...
}); });
isStatic = true; isStatic = true;
@ -115,7 +112,7 @@ rec {
{ mkDerivation = args: stdenv.mkDerivation (args // { { mkDerivation = args: stdenv.mkDerivation (args // {
dontDisableStatic = true; dontDisableStatic = true;
configureFlags = configureFlags =
(if args ? configureFlags then toString args.configureFlags else "") toString args.configureFlags or ""
+ " --enable-static --disable-shared"; + " --enable-static --disable-shared";
}); });
} // {inherit fetchurl;}; } // {inherit fetchurl;};
@ -133,8 +130,8 @@ rec {
# In nixpkgs, sometimes 'null' gets in as a buildInputs element, # In nixpkgs, sometimes 'null' gets in as a buildInputs element,
# and we handle that through isAttrs. # and we handle that through isAttrs.
getBuildDrv = drv : if (builtins.isAttrs drv && drv ? nativeDrv) then drv.nativeDrv else drv; getBuildDrv = drv: drv.nativeDrv or drv;
getHostDrv = drv : if (builtins.isAttrs drv && drv ? crossDrv) then drv.crossDrv else drv; getHostDrv = drv: drv.crossDrv or drv;
nativeBuildInputsDrvs = map (getBuildDrv) nativeBuildInputs; nativeBuildInputsDrvs = map (getBuildDrv) nativeBuildInputs;
buildInputsDrvs = map (getHostDrv) buildInputs; buildInputsDrvs = map (getHostDrv) buildInputs;
buildInputsDrvsAsBuildInputs = map (getBuildDrv) buildInputs; buildInputsDrvsAsBuildInputs = map (getBuildDrv) buildInputs;
@ -177,7 +174,7 @@ rec {
propagatedNativeBuildInputs = propagatedNativeBuildInputsDrvs; propagatedNativeBuildInputs = propagatedNativeBuildInputsDrvs;
crossConfig = cross.config; crossConfig = cross.config;
} // (if args ? crossAttrs then args.crossAttrs else {})); } // args.crossAttrs or {});
in nativeDrv // { in nativeDrv // {
inherit crossDrv nativeDrv; inherit crossDrv nativeDrv;
}; };
@ -297,14 +294,9 @@ rec {
pkg = stdenv.mkDerivation args; pkg = stdenv.mkDerivation args;
printDrvPath = val: let printDrvPath = val: let
drvPath = builtins.unsafeDiscardStringContext pkg.drvPath; drvPath = builtins.unsafeDiscardStringContext pkg.drvPath;
license = license = pkg.meta.license or null;
if pkg ? meta && pkg.meta ? license then
pkg.meta.license
else
null;
in in
builtins.trace "@:drv:${toString drvPath}:${builtins.toString license}:@" builtins.trace "@:drv:${toString drvPath}:${builtins.toString license}:@" val;
val;
in pkg // { in pkg // {
outPath = printDrvPath pkg.outPath; outPath = printDrvPath pkg.outPath;
drvPath = printDrvPath pkg.drvPath; drvPath = printDrvPath pkg.drvPath;
@ -333,15 +325,12 @@ rec {
pkg = stdenv.mkDerivation args; pkg = stdenv.mkDerivation args;
drv = builtins.unsafeDiscardStringContext pkg.drvPath; drv = builtins.unsafeDiscardStringContext pkg.drvPath;
license = license =
if pkg ? meta && pkg.meta ? license then pkg.meta.license or
pkg.meta.license
else if pkg ? outputHash then
# Fixed-output derivations such as source tarballs usually # Fixed-output derivations such as source tarballs usually
# don't have licensing information, but that's OK. # don't have licensing information, but that's OK.
null (pkg.outputHash or
else (builtins.trace
builtins.trace "warning: ${drv} lacks licensing information" null));
"warning: ${drv} lacks licensing information" null;
validate = arg: validate = arg:
if licensePred license then arg if licensePred license then arg