diff --git a/lib/customisation.nix b/lib/customisation.nix index 91a25055df29..ca3dd4980da3 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -158,4 +158,27 @@ 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 5b23e36af83a..bf722431d910 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -27,65 +27,60 @@ , type ? "" }: +with stdenv; with stdenv.lib; let n = "qemu-2.3.0"; - 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; + isKvmOnly = type == "kvm-only"; + isNix = type == "nix"; - 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; + 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; optLibaio = shouldUsePkg libaio; optLibcap_ng = shouldUsePkg libcap_ng; - 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; + 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; hasSDLAbi = if optSDL2 != null then true else null; hasVirtfs = stdenv.isLinux && optLibcap != null && optAttr != null; - hasVnc = type != "nix"; + hasVnc = !isNix; hasVncTls = hasVnc && optGnutls != null; hasVncSasl = hasVnc && optCyrus_sasl != null; hasVncJpeg = hasVnc && optLibjpeg != null; hasVncPng = hasVnc && optLibpng != null; hasVncWs = hasVnc && optGnutls != null; - hasFdt = type != "nix"; + hasFdt = !isNix; hasRdma = optLibibverbs != null && optLibrdmacm != null; @@ -95,8 +90,8 @@ let hasNss = optNss != null && optNspr != null; - optLibpulseaudio = if type == "nix" then null else shouldUsePkg libpulseaudio; - optAlsaLib = if type == "nix" then null else shouldUsePkg alsaLib; + optLibpulseaudio = if isNix then null else shouldUsePkg libpulseaudio; + optAlsaLib = if isNix then null else shouldUsePkg alsaLib; audio = concatStringsSep "," ( optional (optSDL2 != null) "sdl" ++ optional (optLibpulseaudio != null) "pa" @@ -179,9 +174,9 @@ stdenv.mkDerivation rec { (mkEnable (optBluez != null) "bluez" null) (mkEnable stdenv.isLinux "kvm" null) (mkEnable hasRdma "rdma" null) - (mkEnable (type != "nix") "system" null) - (mkEnable (type != "kvm-only") "user" null) - (mkEnable (type != "kvm-only") "guest-base" null) + (mkEnable (!isNix) "system" null) + (mkEnable (!isKvmOnly) "user" null) + (mkEnable (!isKvmOnly) "guest-base" null) (mkEnable true "pie" null) (mkEnable (optLibuuid != null) "uuid" null) (mkEnable (optVde2 != null) "vde" null) @@ -189,7 +184,7 @@ stdenv.mkDerivation rec { (mkEnable hasLinuxAio "linux-aio" null) (mkEnable (optLibcap_ng != null) "cap-ng" null) (mkEnable (optAttr != null) "attr" null) - (mkEnable (type != "nix") "docs" null) + (mkEnable (!isNix) "docs" null) (mkEnable stdenv.isLinux "vhost-net" null) (mkEnable hasSpice "spice" null) (mkEnable (optLibceph != null) "rbd" null) @@ -212,7 +207,7 @@ stdenv.mkDerivation rec { (mkEnable (optLibuuid != null) "vhdx" null) (mkEnable (optGnutls != null) "quorum" null) (mkEnable (optNumactl != null) "numa" null) - ] ++ optionals (type == "kvm-only") [ + ] ++ optionals isKvmOnly [ (mkOther "target-list" targetList) ]; @@ -235,6 +230,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 type == "kvm-only" then platforms.linux else platforms.all; + platforms = if isKvmOnly then platforms.linux else platforms.all; }; } diff --git a/pkgs/development/libraries/kerberos/heimdal.nix b/pkgs/development/libraries/kerberos/heimdal.nix index b0de8c151460..6050891ba272 100644 --- a/pkgs/development/libraries/kerberos/heimdal.nix +++ b/pkgs/development/libraries/kerberos/heimdal.nix @@ -8,16 +8,9 @@ #, 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; @@ -97,7 +90,7 @@ stdenv.mkDerivation rec { rmdir $out/libexec ''; - meta = with stdenv.lib; { + meta = { 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 7d327a499bcc..702d54392a6e 100644 --- a/pkgs/development/libraries/libgcrypt/default.nix +++ b/pkgs/development/libraries/libgcrypt/default.nix @@ -5,16 +5,9 @@ , 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 @@ -38,13 +31,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 - '' + stdenv.lib.optionalString (!stdenv.isDarwin && optLibcap != null) '' + '' + optionalString (!stdenv.isDarwin && optLibcap != null) '' sed -i 's,\(-lcap\),-L${optLibcap}/lib \1,' $out/lib/libgcrypt.la ''; doCheck = true; - meta = with stdenv.lib; { + meta = { 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 9eca6bd84b99..c7892716c9d6 100644 --- a/pkgs/development/libraries/libmicrohttpd/default.nix +++ b/pkgs/development/libraries/libmicrohttpd/default.nix @@ -5,16 +5,8 @@ , 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 e5d01f213cbc..83efa5e65c95 100644 --- a/pkgs/development/libraries/libssh/default.nix +++ b/pkgs/development/libraries/libssh/default.nix @@ -7,9 +7,8 @@ , 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 3434fde1a623..a8e8777f06ca 100644 --- a/pkgs/development/libraries/libssh2/default.nix +++ b/pkgs/development/libraries/libssh2/default.nix @@ -7,16 +7,8 @@ , 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 0d70a6502feb..77050a1d3b38 100644 --- a/pkgs/development/libraries/libxml2/default.nix +++ b/pkgs/development/libraries/libxml2/default.nix @@ -6,16 +6,8 @@ #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; @@ -25,6 +17,7 @@ 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 fd545e53625f..43fca875f58f 100644 --- a/pkgs/development/libraries/ncurses/default.nix +++ b/pkgs/development/libraries/ncurses/default.nix @@ -8,23 +8,11 @@ , 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 = shouldUsePkg gpm; + optGpm = stdenv.shouldUsePkg gpm; in stdenv.mkDerivation rec { name = "ncurses-5.9"; @@ -119,7 +107,7 @@ stdenv.mkDerivation rec { echo "INPUT(-lncurses)" > $out/lib/libcurses.so ''; - meta = with stdenv.lib; { + meta = { 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 bc8c599a901f..d8fd36ecba63 100644 --- a/pkgs/development/libraries/nghttp2/default.nix +++ b/pkgs/development/libraries/nghttp2/default.nix @@ -8,16 +8,9 @@ , 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; @@ -50,7 +43,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkgconfig ]; buildInputs = [ optJansson optBoost optLibxml2 optJemalloc ] - ++ stdenv.lib.optionals hasApp [ optOpenssl optLibev optZlib ]; + ++ optionals hasApp [ optOpenssl optLibev optZlib ]; configureFlags = [ (mkEnable false "werror" null) @@ -68,7 +61,7 @@ stdenv.mkDerivation rec { (mkWith false "cython" null) ]; - meta = with stdenv.lib; { + meta = { 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 da4dc9d6bbc3..514dcd5972af 100644 --- a/pkgs/development/libraries/wiredtiger/default.nix +++ b/pkgs/development/libraries/wiredtiger/default.nix @@ -5,17 +5,8 @@ , gperftools ? null, leveldb ? null }: -with stdenv.lib; +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 && any (x: x == stdenv.system) pkg.meta.platforms then pkg else null; - optLz4 = shouldUsePkg lz4; optSnappy = shouldUsePkg snappy; optZlib = shouldUsePkg zlib; @@ -24,6 +15,7 @@ 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 47511cf58b0e..adddd3ac2116 100644 --- a/pkgs/misc/jackaudio/default.nix +++ b/pkgs/misc/jackaudio/default.nix @@ -9,10 +9,9 @@ , 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 1c5c78548f5b..343c3af9cee7 100644 --- a/pkgs/misc/jackaudio/jack1.nix +++ b/pkgs/misc/jackaudio/jack1.nix @@ -4,9 +4,8 @@ , 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 b0f545b2171f..49a7d820a1cd 100644 --- a/pkgs/os-specific/linux/ffado/default.nix +++ b/pkgs/os-specific/linux/ffado/default.nix @@ -9,10 +9,8 @@ , 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 8dee9a801e36..784b5a2ce94f 100644 --- a/pkgs/servers/pulseaudio/default.nix +++ b/pkgs/servers/pulseaudio/default.nix @@ -15,16 +15,8 @@ , 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; @@ -66,6 +58,7 @@ let simple = null; }.${databaseName}; in +with stdenv.lib; stdenv.mkDerivation rec { name = "${prefix}pulseaudio-${version}"; version = "6.0"; @@ -84,9 +77,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 - ] ++ stdenv.lib.optionals hasXlibs (with xlibs; [ + ] ++ optionals hasXlibs (with xlibs; [ libX11 libxcb libICE libSM libXtst xextproto libXi - ]) ++ stdenv.lib.optionals (optBluez5 != null) [ optBluez5 optSbc ]; + ]) ++ optionals (optBluez5 != null) [ optBluez5 optSbc ]; preConfigure = '' # Performs and autoreconf @@ -162,7 +155,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 = stdenv.lib.optionalString stdenv.isDarwin + NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-I/usr/include"; installFlags = [ @@ -170,11 +163,11 @@ stdenv.mkDerivation rec { "pulseconfdir=$(out)/etc/pulse" ]; - postInstall = stdenv.lib.optionalString libOnly '' + postInstall = optionalString libOnly '' rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}} ''; - meta = with stdenv.lib; { + meta = { 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 a97e6847a450..bc4e57ba116c 100644 --- a/pkgs/servers/shishi/default.nix +++ b/pkgs/servers/shishi/default.nix @@ -5,16 +5,8 @@ , 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 7efd2ead2f8f..440e9e6b4d04 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -229,6 +229,8 @@ 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 ad2c9ec68970..8a101e9845a6 100644 --- a/pkgs/tools/networking/curl/default.nix +++ b/pkgs/tools/networking/curl/default.nix @@ -8,19 +8,12 @@ , 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 = stdenv.lib.optionalString (suffix != "") "-${suffix}"; + nameSuffix = optionalString (suffix != "") "-${suffix}"; # Normal Depedencies optZlib = if isLight then null else shouldUsePkg zlib; @@ -35,7 +28,6 @@ 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";