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

View file

@ -5,9 +5,16 @@
, libcap ? null, pth ? null , libcap ? null, pth ? null
}: }:
with stdenv;
with stdenv.lib;
let 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; optLibcap = shouldUsePkg libcap;
#optPth = shouldUsePkg pth; #optPth = shouldUsePkg pth;
optPth = null; # Broken as of 1.6.3 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 # Also make sure includes are fixed for callers who don't use libgpgcrypt-config
postInstall = '' postInstall = ''
sed -i 's,#include <gpg-error.h>,#include "${libgpgerror}/include/gpg-error.h",g' $out/include/gcrypt.h 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 sed -i 's,\(-lcap\),-L${optLibcap}/lib \1,' $out/lib/libgcrypt.la
''; '';
doCheck = true; doCheck = true;
meta = { meta = with stdenv.lib; {
homepage = https://www.gnu.org/software/libgcrypt/; homepage = https://www.gnu.org/software/libgcrypt/;
description = "General-pupose cryptographic library"; description = "General-pupose cryptographic library";
license = licenses.lgpl2Plus; license = licenses.lgpl2Plus;

View file

@ -5,8 +5,16 @@
, openssl ? null, zlib ? null, libgcrypt ? null, gnutls ? null , openssl ? null, zlib ? null, libgcrypt ? null, gnutls ? null
}: }:
with stdenv;
let 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; optOpenssl = shouldUsePkg openssl;
optZlib = shouldUsePkg zlib; optZlib = shouldUsePkg zlib;
hasSpdy = optOpenssl != null && optZlib != null; hasSpdy = optOpenssl != null && optZlib != null;

View file

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

View file

@ -7,8 +7,16 @@
, openssl ? null, libgcrypt ? null , openssl ? null, libgcrypt ? null
}: }:
with stdenv;
let 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 # Prefer openssl
cryptoStr = if shouldUsePkg openssl != null then "openssl" cryptoStr = if shouldUsePkg openssl != null then "openssl"
else if shouldUsePkg libgcrypt != null then "libgcrypt" 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 #TODO: share most stuff between python and non-python builds, perhaps via multiple-output
with stdenv;
let 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; optIcu = shouldUsePkg icu;
optPython = shouldUsePkg python; optPython = shouldUsePkg python;
optReadline = shouldUsePkg readline; optReadline = shouldUsePkg readline;
@ -17,7 +25,6 @@ let
sitePackages = if optPython == null then null else sitePackages = if optPython == null then null else
"\${out}/lib/${python.libPrefix}/site-packages"; "\${out}/lib/${python.libPrefix}/site-packages";
in in
with stdenv.lib;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "libxml2-${version}"; name = "libxml2-${version}";
version = "2.9.2"; version = "2.9.2";

View file

@ -8,11 +8,23 @@
, unicode ? true , unicode ? true
}: }:
with stdenv.lib;
let 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; buildShared = !stdenv.isDarwin;
optGpm = stdenv.shouldUsePkg gpm; optGpm = shouldUsePkg gpm;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "ncurses-5.9"; name = "ncurses-5.9";
@ -124,7 +136,7 @@ stdenv.mkDerivation rec {
ln -svf libncurses.so $out/lib/libcurses.so ln -svf libncurses.so $out/lib/libcurses.so
''; '';
meta = { meta = with stdenv.lib; {
description = "Free software emulation of curses in SVR4 and more"; description = "Free software emulation of curses in SVR4 and more";
longDescription = '' longDescription = ''

View file

@ -8,9 +8,16 @@
, prefix ? "" , prefix ? ""
}: }:
with stdenv;
with stdenv.lib;
let 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"; isLib = prefix == "lib";
optOpenssl = if isLib then null else shouldUsePkg openssl; optOpenssl = if isLib then null else shouldUsePkg openssl;
@ -43,7 +50,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ pkgconfig ]; nativeBuildInputs = [ pkgconfig ];
buildInputs = [ optJansson optBoost optLibxml2 optJemalloc ] buildInputs = [ optJansson optBoost optLibxml2 optJemalloc ]
++ optionals hasApp [ optOpenssl optLibev optZlib ]; ++ stdenv.lib.optionals hasApp [ optOpenssl optLibev optZlib ];
configureFlags = [ configureFlags = [
(mkEnable false "werror" null) (mkEnable false "werror" null)
@ -61,7 +68,7 @@ stdenv.mkDerivation rec {
(mkWith false "cython" null) (mkWith false "cython" null)
]; ];
meta = { meta = with stdenv.lib; {
homepage = http://nghttp2.org/; homepage = http://nghttp2.org/;
description = "an implementation of HTTP/2 in C"; description = "an implementation of HTTP/2 in C";
license = licenses.mit; license = licenses.mit;

View file

@ -5,8 +5,17 @@
, gperftools ? null, leveldb ? null , gperftools ? null, leveldb ? null
}: }:
with stdenv; with stdenv.lib;
let 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; optLz4 = shouldUsePkg lz4;
optSnappy = shouldUsePkg snappy; optSnappy = shouldUsePkg snappy;
optZlib = shouldUsePkg zlib; optZlib = shouldUsePkg zlib;
@ -15,7 +24,6 @@ let
optGperftools = shouldUsePkg gperftools; optGperftools = shouldUsePkg gperftools;
optLeveldb = shouldUsePkg leveldb; optLeveldb = shouldUsePkg leveldb;
in in
with stdenv.lib;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "wiredtiger-${version}"; name = "wiredtiger-${version}";
version = "2.6.0"; version = "2.6.0";

View file

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

View file

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

View file

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

View file

@ -15,8 +15,16 @@
, prefix ? "" , prefix ? ""
}: }:
with stdenv;
let 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"; libOnly = prefix == "lib";
hasXlibs = xlibs != null; hasXlibs = xlibs != null;
@ -58,7 +66,6 @@ let
simple = null; simple = null;
}.${databaseName}; }.${databaseName};
in in
with stdenv.lib;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "${prefix}pulseaudio-${version}"; name = "${prefix}pulseaudio-${version}";
version = "6.0"; version = "6.0";
@ -77,9 +84,9 @@ stdenv.mkDerivation rec {
optLibcap valgrind optOss optCoreaudio optAlsaLib optEsound optGlib optLibcap valgrind optOss optCoreaudio optAlsaLib optEsound optGlib
optGtk3 optGconf optAvahi optLibjack2 optLibasyncns optLirc optDbus optUdev optGtk3 optGconf optAvahi optLibjack2 optLibasyncns optLirc optDbus optUdev
optOpenssl optFftw optSpeexdsp optSystemd optWebrtc-audio-processing optOpenssl optFftw optSpeexdsp optSystemd optWebrtc-audio-processing
] ++ optionals hasXlibs (with xlibs; [ ] ++ stdenv.lib.optionals hasXlibs (with xlibs; [
libX11 libxcb libICE libSM libXtst xextproto libXi libX11 libxcb libICE libSM libXtst xextproto libXi
]) ++ optionals (optBluez5 != null) [ optBluez5 optSbc ]; ]) ++ stdenv.lib.optionals (optBluez5 != null) [ optBluez5 optSbc ];
preConfigure = '' preConfigure = ''
# Performs and autoreconf # 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 # 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 # probably a large number of files that would need to be copied (I stopped
# after the seventh) # after the seventh)
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin
"-I/usr/include"; "-I/usr/include";
installFlags = [ installFlags = [
@ -163,11 +170,11 @@ stdenv.mkDerivation rec {
"pulseconfdir=$(out)/etc/pulse" "pulseconfdir=$(out)/etc/pulse"
]; ];
postInstall = optionalString libOnly '' postInstall = stdenv.lib.optionalString libOnly ''
rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}} rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}}
''; '';
meta = { meta = with stdenv.lib; {
description = "Sound server for POSIX and Win32 systems"; description = "Sound server for POSIX and Win32 systems";
homepage = http://www.pulseaudio.org/; homepage = http://www.pulseaudio.org/;
# Note: Practically, the server is under the GPL due to the # Note: Practically, the server is under the GPL due to the

View file

@ -5,8 +5,16 @@
, pam ? null, libidn ? null, gnutls ? null , pam ? null, libidn ? null, gnutls ? null
}: }:
with stdenv;
let 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; optPam = shouldUsePkg pam;
optLibidn = shouldUsePkg libidn; optLibidn = shouldUsePkg libidn;
optGnutls = shouldUsePkg gnutls; optGnutls = shouldUsePkg gnutls;

View file

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

View file

@ -8,12 +8,19 @@
, suffix ? "" , suffix ? ""
}: }:
with stdenv;
with stdenv.lib;
let 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"; isLight = suffix == "light";
isFull = suffix == "full"; isFull = suffix == "full";
nameSuffix = optionalString (suffix != "") "-${suffix}"; nameSuffix = stdenv.lib.optionalString (suffix != "") "-${suffix}";
# Normal Depedencies # Normal Depedencies
optZlib = if isLight then null else shouldUsePkg zlib; optZlib = if isLight then null else shouldUsePkg zlib;
@ -28,6 +35,7 @@ let
optOpenldap = if !isFull then null else shouldUsePkg openldap; optOpenldap = if !isFull then null else shouldUsePkg openldap;
optLibidn = if !isFull then null else shouldUsePkg libidn; optLibidn = if !isFull then null else shouldUsePkg libidn;
in in
with stdenv.lib;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "curl${nameSuffix}-${version}"; name = "curl${nameSuffix}-${version}";
version = "7.42.1"; version = "7.42.1";