diff --git a/lib/customisation.nix b/lib/customisation.nix index ca3dd4980da..91a25055df2 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -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; } diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index 0d57a8d9f57..f9433a1a409 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -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; }; } diff --git a/pkgs/development/libraries/kerberos/heimdal.nix b/pkgs/development/libraries/kerberos/heimdal.nix index 6050891ba27..b0de8c15146 100644 --- a/pkgs/development/libraries/kerberos/heimdal.nix +++ b/pkgs/development/libraries/kerberos/heimdal.nix @@ -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; diff --git a/pkgs/development/libraries/libgcrypt/default.nix b/pkgs/development/libraries/libgcrypt/default.nix index 702d54392a6..7d327a499bc 100644 --- a/pkgs/development/libraries/libgcrypt/default.nix +++ b/pkgs/development/libraries/libgcrypt/default.nix @@ -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 ,#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; diff --git a/pkgs/development/libraries/libmicrohttpd/default.nix b/pkgs/development/libraries/libmicrohttpd/default.nix index c7892716c9d..9eca6bd84b9 100644 --- a/pkgs/development/libraries/libmicrohttpd/default.nix +++ b/pkgs/development/libraries/libmicrohttpd/default.nix @@ -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; diff --git a/pkgs/development/libraries/libssh/default.nix b/pkgs/development/libraries/libssh/default.nix index 8ea2ac72da0..17bcf227c0e 100644 --- a/pkgs/development/libraries/libssh/default.nix +++ b/pkgs/development/libraries/libssh/default.nix @@ -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" diff --git a/pkgs/development/libraries/libssh2/default.nix b/pkgs/development/libraries/libssh2/default.nix index a8e8777f06c..3434fde1a62 100644 --- a/pkgs/development/libraries/libssh2/default.nix +++ b/pkgs/development/libraries/libssh2/default.nix @@ -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" diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix index 77050a1d3b3..0d70a6502fe 100644 --- a/pkgs/development/libraries/libxml2/default.nix +++ b/pkgs/development/libraries/libxml2/default.nix @@ -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"; diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix index f0519fa981d..bea4754a1f5 100644 --- a/pkgs/development/libraries/ncurses/default.nix +++ b/pkgs/development/libraries/ncurses/default.nix @@ -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 = '' diff --git a/pkgs/development/libraries/nghttp2/default.nix b/pkgs/development/libraries/nghttp2/default.nix index d8fd36ecba6..bc8c599a901 100644 --- a/pkgs/development/libraries/nghttp2/default.nix +++ b/pkgs/development/libraries/nghttp2/default.nix @@ -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; diff --git a/pkgs/development/libraries/wiredtiger/default.nix b/pkgs/development/libraries/wiredtiger/default.nix index 514dcd5972a..da4dc9d6bbc 100644 --- a/pkgs/development/libraries/wiredtiger/default.nix +++ b/pkgs/development/libraries/wiredtiger/default.nix @@ -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"; diff --git a/pkgs/misc/jackaudio/default.nix b/pkgs/misc/jackaudio/default.nix index adddd3ac211..47511cf58b0 100644 --- a/pkgs/misc/jackaudio/default.nix +++ b/pkgs/misc/jackaudio/default.nix @@ -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; diff --git a/pkgs/misc/jackaudio/jack1.nix b/pkgs/misc/jackaudio/jack1.nix index 343c3af9cee..1c5c78548f5 100644 --- a/pkgs/misc/jackaudio/jack1.nix +++ b/pkgs/misc/jackaudio/jack1.nix @@ -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; diff --git a/pkgs/os-specific/linux/ffado/default.nix b/pkgs/os-specific/linux/ffado/default.nix index 49a7d820a1c..b0f545b2171 100644 --- a/pkgs/os-specific/linux/ffado/default.nix +++ b/pkgs/os-specific/linux/ffado/default.nix @@ -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; diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix index 3930c45a097..8196caa08d9 100644 --- a/pkgs/servers/pulseaudio/default.nix +++ b/pkgs/servers/pulseaudio/default.nix @@ -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 diff --git a/pkgs/servers/shishi/default.nix b/pkgs/servers/shishi/default.nix index bc4e57ba116..a97e6847a45 100644 --- a/pkgs/servers/shishi/default.nix +++ b/pkgs/servers/shishi/default.nix @@ -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; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index cca89487462..863acc31a61 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -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; diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix index 8a101e9845a..ad2c9ec6897 100644 --- a/pkgs/tools/networking/curl/default.nix +++ b/pkgs/tools/networking/curl/default.nix @@ -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";