Revert "Refactor mkFlag / shouldUsePkg into the nixpkgs libraries"

This reverts commit 25a148fa19.
This commit is contained in:
Eelco Dolstra 2015-06-01 20:52:03 +02:00
parent 4f60156afb
commit 3096d03435
18 changed files with 176 additions and 104 deletions

View file

@ -158,27 +158,4 @@ rec {
drv' = (lib.head outputsList).value;
in lib.deepSeq drv' drv';
/* Tests whether a derivation can be used by the current platform
Returns the derivation if true, otherwise null. */
shouldUsePkgSystem = system: pkg_: let pkg = (builtins.tryEval pkg_).value;
in if lib.any (x: x == system) (pkg.meta.platforms or [])
then pkg
else null;
/* Returns a configure flag string in an autotools format
trueStr: Prepended when cond is true
falseStr: Prepended when cond is false
cond: The condition for the prepended string type and value
name: The flag name
val: The value of the flag only set when cond is true */
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}"
+ "${if val != null && cond != false then "=${val}" else ""}";
/* Flag setting helpers for autotools like packages */
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
}

View file

@ -17,60 +17,65 @@
, type ? ""
}:
with stdenv;
with stdenv.lib;
let
n = "qemu-2.3.0";
isKvmOnly = type == "kvm-only";
isNix = type == "nix";
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
optSDL2 = if isNix then null else shouldUsePkg SDL2;
optGtk = if isNix then null else shouldUsePkg gtk;
optLibcap = if isNix then null else shouldUsePkg libcap;
optAttr = if isNix then null else shouldUsePkg attr;
optGnutls = if isNix then null else shouldUsePkg gnutls;
optCyrus_sasl = if isNix then null else shouldUsePkg cyrus_sasl;
optLibjpeg = if isNix then null else shouldUsePkg libjpeg;
optLibpng = if isNix then null else shouldUsePkg libpng;
optNcurses = if isNix then null else shouldUsePkg ncurses;
optCurl = if isNix then null else shouldUsePkg curl;
optBluez = if isNix then null else shouldUsePkg bluez;
optLibibverbs = if isNix then null else shouldUsePkg libibverbs;
optLibrdmacm = if isNix then null else shouldUsePkg librdmacm;
optLibuuid = if isNix then null else shouldUsePkg libuuid;
optVde2 = if isNix then null else shouldUsePkg vde2;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optSDL2 = if type == "nix" then null else shouldUsePkg SDL2;
optGtk = if type == "nix" then null else shouldUsePkg gtk;
optLibcap = if type == "nix" then null else shouldUsePkg libcap;
optAttr = if type == "nix" then null else shouldUsePkg attr;
optGnutls = if type == "nix" then null else shouldUsePkg gnutls;
optCyrus_sasl = if type == "nix" then null else shouldUsePkg cyrus_sasl;
optLibjpeg = if type == "nix" then null else shouldUsePkg libjpeg;
optLibpng = if type == "nix" then null else shouldUsePkg libpng;
optNcurses = if type == "nix" then null else shouldUsePkg ncurses;
optCurl = if type == "nix" then null else shouldUsePkg curl;
optBluez = if type == "nix" then null else shouldUsePkg bluez;
optLibibverbs = if type == "nix" then null else shouldUsePkg libibverbs;
optLibrdmacm = if type == "nix" then null else shouldUsePkg librdmacm;
optLibuuid = if type == "nix" then null else shouldUsePkg libuuid;
optVde2 = if type == "nix" then null else shouldUsePkg vde2;
optLibaio = shouldUsePkg libaio;
optLibcap_ng = shouldUsePkg libcap_ng;
optSpice = if isNix then null else shouldUsePkg spice;
optSpice_protocol = if isNix then null else shouldUsePkg spice_protocol;
optLibceph = if isNix then null else shouldUsePkg libceph;
optLibxfs = if isNix then null else shouldUsePkg libxfs;
optNss = if isNix then null else shouldUsePkg nss;
optNspr = if isNix then null else shouldUsePkg nspr;
optLibusb = if isNix then null else shouldUsePkg libusb;
optUsbredir = if isNix then null else shouldUsePkg usbredir;
optMesa = if isNix then null else shouldUsePkg mesa;
optLzo = if isNix then null else shouldUsePkg lzo;
optSnappy = if isNix then null else shouldUsePkg snappy;
optBzip2 = if isNix then null else shouldUsePkg bzip2;
optLibseccomp = if isNix then null else shouldUsePkg libseccomp;
optGlusterfs = if isNix then null else shouldUsePkg glusterfs;
optLibssh2 = if isNix then null else shouldUsePkg libssh2;
optNumactl = if isNix then null else shouldUsePkg numactl;
optSpice = if type == "nix" then null else shouldUsePkg spice;
optSpice_protocol = if type == "nix" then null else shouldUsePkg spice_protocol;
optLibceph = if type == "nix" then null else shouldUsePkg libceph;
optLibxfs = if type == "nix" then null else shouldUsePkg libxfs;
optNss = if type == "nix" then null else shouldUsePkg nss;
optNspr = if type == "nix" then null else shouldUsePkg nspr;
optLibusb = if type == "nix" then null else shouldUsePkg libusb;
optUsbredir = if type == "nix" then null else shouldUsePkg usbredir;
optMesa = if type == "nix" then null else shouldUsePkg mesa;
optLzo = if type == "nix" then null else shouldUsePkg lzo;
optSnappy = if type == "nix" then null else shouldUsePkg snappy;
optBzip2 = if type == "nix" then null else shouldUsePkg bzip2;
optLibseccomp = if type == "nix" then null else shouldUsePkg libseccomp;
optGlusterfs = if type == "nix" then null else shouldUsePkg glusterfs;
optLibssh2 = if type == "nix" then null else shouldUsePkg libssh2;
optNumactl = if type == "nix" then null else shouldUsePkg numactl;
hasSDLAbi = if optSDL2 != null then true else null;
hasVirtfs = stdenv.isLinux && optLibcap != null && optAttr != null;
hasVnc = !isNix;
hasVnc = type != "nix";
hasVncTls = hasVnc && optGnutls != null;
hasVncSasl = hasVnc && optCyrus_sasl != null;
hasVncJpeg = hasVnc && optLibjpeg != null;
hasVncPng = hasVnc && optLibpng != null;
hasVncWs = hasVnc && optGnutls != null;
hasFdt = !isNix;
hasFdt = type != "nix";
hasRdma = optLibibverbs != null && optLibrdmacm != null;
@ -80,8 +85,8 @@ let
hasNss = optNss != null && optNspr != null;
optLibpulseaudio = if isNix then null else shouldUsePkg libpulseaudio;
optAlsaLib = if isNix then null else shouldUsePkg alsaLib;
optLibpulseaudio = if type == "nix" then null else shouldUsePkg libpulseaudio;
optAlsaLib = if type == "nix" then null else shouldUsePkg alsaLib;
audio = concatStringsSep "," (
optional (optSDL2 != null) "sdl"
++ optional (optLibpulseaudio != null) "pa"
@ -164,9 +169,9 @@ stdenv.mkDerivation rec {
(mkEnable (optBluez != null) "bluez" null)
(mkEnable stdenv.isLinux "kvm" null)
(mkEnable hasRdma "rdma" null)
(mkEnable (!isNix) "system" null)
(mkEnable (!isKvmOnly) "user" null)
(mkEnable (!isKvmOnly) "guest-base" null)
(mkEnable (type != "nix") "system" null)
(mkEnable (type != "kvm-only") "user" null)
(mkEnable (type != "kvm-only") "guest-base" null)
(mkEnable true "pie" null)
(mkEnable (optLibuuid != null) "uuid" null)
(mkEnable (optVde2 != null) "vde" null)
@ -174,7 +179,7 @@ stdenv.mkDerivation rec {
(mkEnable hasLinuxAio "linux-aio" null)
(mkEnable (optLibcap_ng != null) "cap-ng" null)
(mkEnable (optAttr != null) "attr" null)
(mkEnable (!isNix) "docs" null)
(mkEnable (type != "nix") "docs" null)
(mkEnable stdenv.isLinux "vhost-net" null)
(mkEnable hasSpice "spice" null)
(mkEnable (optLibceph != null) "rbd" null)
@ -197,7 +202,7 @@ stdenv.mkDerivation rec {
(mkEnable (optLibuuid != null) "vhdx" null)
(mkEnable (optGnutls != null) "quorum" null)
(mkEnable (optNumactl != null) "numa" null)
] ++ optionals isKvmOnly [
] ++ optionals (type == "kvm-only") [
(mkOther "target-list" targetList)
];
@ -220,6 +225,6 @@ stdenv.mkDerivation rec {
description = "A generic and open source machine emulator and virtualizer";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ viric shlevy eelco wkennington ];
platforms = if isKvmOnly then platforms.linux else platforms.all;
platforms = if type == "kvm-only" then platforms.linux else platforms.all;
};
}

View file

@ -8,9 +8,16 @@
#, sqlite, db, ncurses, openssl, cyrus_sasl
}:
with stdenv;
with stdenv.lib;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optOpenldap = shouldUsePkg openldap;
optLibcap_ng = shouldUsePkg libcap_ng;
optSqlite = shouldUsePkg sqlite;
@ -90,7 +97,7 @@ stdenv.mkDerivation rec {
rmdir $out/libexec
'';
meta = {
meta = with stdenv.lib; {
description = "an implementation of Kerberos 5 (and some more stuff) largely written in Sweden";
license = licenses.bsd3;
platforms = platforms.linux;

View file

@ -5,9 +5,16 @@
, libcap ? null, pth ? null
}:
with stdenv;
with stdenv.lib;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optLibcap = shouldUsePkg libcap;
#optPth = shouldUsePkg pth;
optPth = null; # Broken as of 1.6.3
@ -31,13 +38,13 @@ stdenv.mkDerivation rec {
# Also make sure includes are fixed for callers who don't use libgpgcrypt-config
postInstall = ''
sed -i 's,#include <gpg-error.h>,#include "${libgpgerror}/include/gpg-error.h",g' $out/include/gcrypt.h
'' + optionalString (!stdenv.isDarwin && optLibcap != null) ''
'' + stdenv.lib.optionalString (!stdenv.isDarwin && optLibcap != null) ''
sed -i 's,\(-lcap\),-L${optLibcap}/lib \1,' $out/lib/libgcrypt.la
'';
doCheck = true;
meta = {
meta = with stdenv.lib; {
homepage = https://www.gnu.org/software/libgcrypt/;
description = "General-pupose cryptographic library";
license = licenses.lgpl2Plus;

View file

@ -5,8 +5,16 @@
, openssl ? null, zlib ? null, libgcrypt ? null, gnutls ? null
}:
with stdenv;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optOpenssl = shouldUsePkg openssl;
optZlib = shouldUsePkg zlib;
hasSpdy = optOpenssl != null && optZlib != null;

View file

@ -7,8 +7,9 @@
, openssl ? null, libgcrypt ? null
}:
with stdenv;
let
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
# Prefer openssl
cryptoStr = if shouldUsePkg openssl != null then "openssl"
else if shouldUsePkg libgcrypt != null then "libgcrypt"

View file

@ -7,8 +7,16 @@
, openssl ? null, libgcrypt ? null
}:
with stdenv;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
# Prefer openssl
cryptoStr = if shouldUsePkg openssl != null then "openssl"
else if shouldUsePkg libgcrypt != null then "libgcrypt"

View file

@ -6,8 +6,16 @@
#TODO: share most stuff between python and non-python builds, perhaps via multiple-output
with stdenv;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optIcu = shouldUsePkg icu;
optPython = shouldUsePkg python;
optReadline = shouldUsePkg readline;
@ -17,7 +25,6 @@ let
sitePackages = if optPython == null then null else
"\${out}/lib/${python.libPrefix}/site-packages";
in
with stdenv.lib;
stdenv.mkDerivation rec {
name = "libxml2-${version}";
version = "2.9.2";

View file

@ -8,11 +8,23 @@
, unicode ? true
}:
with stdenv.lib;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg_: let
pkg = (builtins.tryEval pkg_).value;
in if stdenv.lib.any (x: x == stdenv.system) (pkg.meta.platforms or [])
then pkg
else null;
buildShared = !stdenv.isDarwin;
optGpm = stdenv.shouldUsePkg gpm;
optGpm = shouldUsePkg gpm;
in
stdenv.mkDerivation rec {
name = "ncurses-5.9";
@ -124,7 +136,7 @@ stdenv.mkDerivation rec {
ln -svf libncurses.so $out/lib/libcurses.so
'';
meta = {
meta = with stdenv.lib; {
description = "Free software emulation of curses in SVR4 and more";
longDescription = ''

View file

@ -8,9 +8,16 @@
, prefix ? ""
}:
with stdenv;
with stdenv.lib;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
isLib = prefix == "lib";
optOpenssl = if isLib then null else shouldUsePkg openssl;
@ -43,7 +50,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ optJansson optBoost optLibxml2 optJemalloc ]
++ optionals hasApp [ optOpenssl optLibev optZlib ];
++ stdenv.lib.optionals hasApp [ optOpenssl optLibev optZlib ];
configureFlags = [
(mkEnable false "werror" null)
@ -61,7 +68,7 @@ stdenv.mkDerivation rec {
(mkWith false "cython" null)
];
meta = {
meta = with stdenv.lib; {
homepage = http://nghttp2.org/;
description = "an implementation of HTTP/2 in C";
license = licenses.mit;

View file

@ -5,8 +5,17 @@
, gperftools ? null, leveldb ? null
}:
with stdenv;
with stdenv.lib;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optLz4 = shouldUsePkg lz4;
optSnappy = shouldUsePkg snappy;
optZlib = shouldUsePkg zlib;
@ -15,7 +24,6 @@ let
optGperftools = shouldUsePkg gperftools;
optLeveldb = shouldUsePkg leveldb;
in
with stdenv.lib;
stdenv.mkDerivation rec {
name = "wiredtiger-${version}";
version = "2.6.0";

View file

@ -9,9 +9,10 @@
, prefix ? ""
}:
with stdenv;
with stdenv.lib;
let
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
libOnly = prefix == "lib";
optDbus = shouldUsePkg dbus;

View file

@ -4,8 +4,9 @@
, alsaLib ? null, db ? null, libuuid ? null, libffado ? null, celt ? null
}:
with stdenv;
let
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optAlsaLib = shouldUsePkg alsaLib;
optDb = shouldUsePkg db;
optLibuuid = shouldUsePkg libuuid;

View file

@ -9,8 +9,10 @@
, prefix ? ""
}:
with stdenv;
let
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
libOnly = prefix == "lib";
optLibjack2 = shouldUsePkg libjack2;

View file

@ -15,8 +15,16 @@
, prefix ? ""
}:
with stdenv;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
libOnly = prefix == "lib";
hasXlibs = xlibs != null;
@ -58,7 +66,6 @@ let
simple = null;
}.${databaseName};
in
with stdenv.lib;
stdenv.mkDerivation rec {
name = "${prefix}pulseaudio-${version}";
version = "6.0";
@ -77,9 +84,9 @@ stdenv.mkDerivation rec {
optLibcap valgrind optOss optCoreaudio optAlsaLib optEsound optGlib
optGtk3 optGconf optAvahi optLibjack2 optLibasyncns optLirc optDbus optUdev
optOpenssl optFftw optSpeexdsp optSystemd optWebrtc-audio-processing
] ++ optionals hasXlibs (with xlibs; [
] ++ stdenv.lib.optionals hasXlibs (with xlibs; [
libX11 libxcb libICE libSM libXtst xextproto libXi
]) ++ optionals (optBluez5 != null) [ optBluez5 optSbc ];
]) ++ stdenv.lib.optionals (optBluez5 != null) [ optBluez5 optSbc ];
preConfigure = ''
# Performs and autoreconf
@ -155,7 +162,7 @@ stdenv.mkDerivation rec {
# the alternative is to copy the files from /usr/include to src, but there are
# probably a large number of files that would need to be copied (I stopped
# after the seventh)
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin
NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin
"-I/usr/include";
installFlags = [
@ -163,11 +170,11 @@ stdenv.mkDerivation rec {
"pulseconfdir=$(out)/etc/pulse"
];
postInstall = optionalString libOnly ''
postInstall = stdenv.lib.optionalString libOnly ''
rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}}
'';
meta = {
meta = with stdenv.lib; {
description = "Sound server for POSIX and Win32 systems";
homepage = http://www.pulseaudio.org/;
# Note: Practically, the server is under the GPL due to the

View file

@ -5,8 +5,16 @@
, pam ? null, libidn ? null, gnutls ? null
}:
with stdenv;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optPam = shouldUsePkg pam;
optLibidn = shouldUsePkg libidn;
optGnutls = shouldUsePkg gnutls;

View file

@ -232,8 +232,6 @@ let
|| system == "armv7l-linux";
isBigEndian = system == "powerpc-linux";
shouldUsePkg = lib.shouldUsePkgSystem system;
# Whether we should run paxctl to pax-mark binaries.
needsPax = isLinux;

View file

@ -8,12 +8,19 @@
, suffix ? ""
}:
with stdenv;
with stdenv.lib;
let
mkFlag = trueStr: falseStr: cond: name: val:
if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
isLight = suffix == "light";
isFull = suffix == "full";
nameSuffix = optionalString (suffix != "") "-${suffix}";
nameSuffix = stdenv.lib.optionalString (suffix != "") "-${suffix}";
# Normal Depedencies
optZlib = if isLight then null else shouldUsePkg zlib;
@ -28,6 +35,7 @@ let
optOpenldap = if !isFull then null else shouldUsePkg openldap;
optLibidn = if !isFull then null else shouldUsePkg libidn;
in
with stdenv.lib;
stdenv.mkDerivation rec {
name = "curl${nameSuffix}-${version}";
version = "7.42.1";