Refactor mkFlag / shouldUsePkg into the nixpkgs libraries

This commit is contained in:
William A. Kennington III
2015-05-22 13:26:55 -07:00
parent 50fa9d8eea
commit 25a148fa19
18 changed files with 104 additions and 176 deletions
+7 -14
View File
@@ -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