Merge pull request #179611 from prusnak/mkflag-remove

remove mkFlag usage where lib.enableFeature and/or lib.withFeature can be used
This commit is contained in:
Pavol Rusnak 2022-07-19 19:41:01 +02:00 committed by GitHub
commit 3e3c3643c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 153 additions and 190 deletions

View File

@ -24,11 +24,7 @@
, withDebug ? false
}:
let
opt = lib.optional;
mkFlag = c: f: if c then "--with-${f}" else "--without-${f}";
in stdenv.mkDerivation rec {
stdenv.mkDerivation rec {
pname = "moc";
version = "2.5.2";
@ -39,56 +35,56 @@ in stdenv.mkDerivation rec {
};
patches = []
++ opt ffmpegSupport ./moc-ffmpeg4.patch
++ opt pulseSupport ./pulseaudio.patch;
++ lib.optional ffmpegSupport ./moc-ffmpeg4.patch
++ lib.optional pulseSupport ./pulseaudio.patch;
nativeBuildInputs = [ pkg-config ]
++ opt pulseSupport autoreconfHook;
++ lib.optional pulseSupport autoreconfHook;
buildInputs = [ ncurses db popt libtool ]
# Sound sub-systems
++ opt alsaSupport alsa-lib
++ opt pulseSupport libpulseaudio
++ opt jackSupport libjack2
++ lib.optional alsaSupport alsa-lib
++ lib.optional pulseSupport libpulseaudio
++ lib.optional jackSupport libjack2
# Audio formats
++ opt (aacSupport || mp3Support) libid3tag
++ opt aacSupport faad2
++ opt flacSupport flac
++ opt midiSupport timidity
++ opt modplugSupport libmodplug
++ opt mp3Support libmad
++ lib.optional (aacSupport || mp3Support) libid3tag
++ lib.optional aacSupport faad2
++ lib.optional flacSupport flac
++ lib.optional midiSupport timidity
++ lib.optional modplugSupport libmodplug
++ lib.optional mp3Support libmad
++ lib.optionals musepackSupport [ libmpc libmpcdec taglib ]
++ opt vorbisSupport libvorbis
++ opt speexSupport speex
++ opt ffmpegSupport ffmpeg
++ opt sndfileSupport libsndfile
++ opt wavpackSupport wavpack
++ lib.optional vorbisSupport libvorbis
++ lib.optional speexSupport speex
++ lib.optional ffmpegSupport ffmpeg
++ lib.optional sndfileSupport libsndfile
++ lib.optional wavpackSupport wavpack
# Misc
++ opt curlSupport curl
++ opt samplerateSupport libsamplerate
++ lib.optional curlSupport curl
++ lib.optional samplerateSupport libsamplerate
++ lib.optionals stdenv.isDarwin [ libiconv CoreServices ];
configureFlags = [
# Sound sub-systems
(mkFlag alsaSupport "alsa")
(mkFlag pulseSupport "pulse")
(mkFlag jackSupport "jack")
(mkFlag ossSupport "oss")
(lib.withFeature alsaSupport "alsa")
(lib.withFeature pulseSupport "pulse")
(lib.withFeature jackSupport "jack")
(lib.withFeature ossSupport "oss")
# Audio formats
(mkFlag aacSupport "aac")
(mkFlag flacSupport "flac")
(mkFlag midiSupport "timidity")
(mkFlag modplugSupport "modplug")
(mkFlag mp3Support "mp3")
(mkFlag musepackSupport "musepack")
(mkFlag vorbisSupport "vorbis")
(mkFlag speexSupport "speex")
(mkFlag ffmpegSupport "ffmpeg")
(mkFlag sndfileSupport "sndfile")
(mkFlag wavpackSupport "wavpack")
(lib.withFeature aacSupport "aac")
(lib.withFeature flacSupport "flac")
(lib.withFeature midiSupport "timidity")
(lib.withFeature modplugSupport "modplug")
(lib.withFeature mp3Support "mp3")
(lib.withFeature musepackSupport "musepack")
(lib.withFeature vorbisSupport "vorbis")
(lib.withFeature speexSupport "speex")
(lib.withFeature ffmpegSupport "ffmpeg")
(lib.withFeature sndfileSupport "sndfile")
(lib.withFeature wavpackSupport "wavpack")
# Misc
(mkFlag curlSupport "curl")
(mkFlag samplerateSupport "samplerate")
(lib.withFeature curlSupport "curl")
(lib.withFeature samplerateSupport "samplerate")
("--enable-debug=" + (if withDebug then "yes" else "no"))
"--disable-cache"
"--without-rcc"

View File

@ -11,10 +11,6 @@
, debugSupport ? false # Debugging (disables optimizations)
}:
let
mkFlag = optSet: flag: if optSet then "--enable-${flag}" else "--disable-${flag}";
in
with lib;
stdenv.mkDerivation rec {
pname = "lame";
@ -37,16 +33,16 @@ stdenv.mkDerivation rec {
++ optional sndfileFileIOSupport libsndfile;
configureFlags = [
(mkFlag nasmSupport "nasm")
(mkFlag cpmlSupport "cpml")
#(mkFlag efenceSupport "efence")
(enableFeature nasmSupport "nasm")
(enableFeature cpmlSupport "cpml")
#(enableFeature efenceSupport "efence")
(if sndfileFileIOSupport then "--with-fileio=sndfile" else "--with-fileio=lame")
(mkFlag analyzerHooksSupport "analyzer-hooks")
(mkFlag decoderSupport "decoder")
(mkFlag frontendSupport "frontend")
(mkFlag frontendSupport "dynamic-frontends")
#(mkFlag mp3xSupport "mp3x")
(mkFlag mp3rtpSupport "mp3rtp")
(enableFeature analyzerHooksSupport "analyzer-hooks")
(enableFeature decoderSupport "decoder")
(enableFeature frontendSupport "frontend")
(enableFeature frontendSupport "dynamic-frontends")
#(enableFeature mp3xSupport "mp3x")
(enableFeature mp3rtpSupport "mp3rtp")
(if debugSupport then "--enable-debug=alot" else "")
];

View File

@ -8,10 +8,6 @@
assert fontconfigSupport -> fontconfig != null;
let
mkFlag = optSet: flag: if optSet then "--enable-${flag}" else "--disable-${flag}";
in
with lib;
stdenv.mkDerivation rec {
pname = "libass";
@ -23,9 +19,9 @@ stdenv.mkDerivation rec {
};
configureFlags = [
(mkFlag fontconfigSupport "fontconfig")
(mkFlag rasterizerSupport "rasterizer")
(mkFlag largeTilesSupport "large-tiles")
(enableFeature fontconfigSupport "fontconfig")
(enableFeature rasterizerSupport "rasterizer")
(enableFeature largeTilesSupport "large-tiles")
];
nativeBuildInputs = [ pkg-config yasm ];

View File

@ -9,8 +9,6 @@ assert avahiSupport -> avahi != null;
assert gtkWidgets -> gtk3 != null;
let
mkFlag = flag: feature: (if flag then "--with-" else "--without-") + feature;
self = stdenv.mkDerivation rec {
pname = "libinfinity";
version = "0.7.2";
@ -29,13 +27,13 @@ let
propagatedBuildInputs = [ gnutls ];
configureFlags = [
"--enable-gtk-doc"
"--enable-introspection"
(mkFlag gtkWidgets "inftextgtk")
(mkFlag gtkWidgets "infgtk")
"--with-infinoted"
"--with-libdaemon"
(mkFlag avahiSupport "avahi")
(lib.enableFeature true "gtk-doc")
(lib.enableFeature true "introspection")
(lib.withFeature gtkWidgets "inftextgtk")
(lib.withFeature gtkWidgets "infgtk")
(lib.withFeature true "infinoted")
(lib.withFeature true "libdaemon")
(lib.withFeature avahiSupport "avahi")
];
passthru = {

View File

@ -7,13 +7,6 @@
with lib;
let
mkFlag = trueStr: falseStr: cond: name: val: "--"
+ (if cond then trueStr else falseStr)
+ name
+ optionalString (val != null && cond != false) "=${val}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optLz4 = shouldUsePkg lz4;
@ -39,19 +32,19 @@ stdenv.mkDerivation rec {
buildInputs = [ optLz4 optSnappy optZlib optBzip2 optDb optGperftools optLeveldb ];
configureFlags = [
(mkWith false "attach" null)
(mkWith true "builtins" "")
(mkEnable (optBzip2 != null) "bzip2" null)
(mkEnable false "diagnostic" null)
(mkEnable false "java" null)
(mkEnable (optLeveldb != null) "leveldb" null)
(mkEnable false "python" null)
(mkEnable (optSnappy != null) "snappy" null)
(mkEnable (optLz4 != null) "lz4" null)
(mkEnable (optGperftools != null) "tcmalloc" null)
(mkEnable (optZlib != null) "zlib" null)
(mkWith (optDb != null) "berkeleydb" optDb)
(mkWith false "helium" null)
(withFeature false "attach")
(withFeatureAs true "builtins" "")
(enableFeature (optBzip2 != null) "bzip2")
(enableFeature false "diagnostic")
(enableFeature false "java")
(enableFeature (optLeveldb != null) "leveldb")
(enableFeature false "python")
(enableFeature (optSnappy != null) "snappy")
(enableFeature (optLz4 != null) "lz4")
(enableFeature (optGperftools != null) "tcmalloc")
(enableFeature (optZlib != null) "zlib")
(withFeatureAs (optDb != null) "berkeleydb" optDb)
(withFeature false "helium")
];
preConfigure = ''

View File

@ -6,14 +6,6 @@
}:
let
mkFlag = trueStr: falseStr: cond: name: val: "--"
+ (if cond then trueStr else falseStr)
+ name
+ lib.optionalString (val != null && cond != false) "=${val}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optPam = shouldUsePkg pam;
@ -37,19 +29,19 @@ stdenv.mkDerivation rec {
buildInputs = [ libgcrypt libgpg-error libtasn1 optPam optLibidn optGnutls ];
configureFlags = [
(mkOther "sysconfdir" "/etc")
(mkOther "localstatedir" "/var")
(mkEnable true "libgcrypt" null)
(mkEnable (optPam != null) "pam" null)
(mkEnable true "ipv6" null)
(mkWith (optLibidn != null) "stringprep" null)
(mkEnable (optGnutls != null) "starttls" null)
(mkEnable true "des" null)
(mkEnable true "3des" null)
(mkEnable true "aes" null)
(mkEnable true "md" null)
(mkEnable false "null" null)
(mkEnable true "arcfour" null)
"--sysconfdir=/etc"
"--localstatedir=/var"
(enableFeature true "libgcrypt")
(enableFeature (optPam != null) "pam")
(enableFeature true "ipv6")
(withFeature (optLibidn != null) "stringprep")
(enableFeature (optGnutls != null) "starttls")
(enableFeature true "des")
(enableFeature true "3des")
(enableFeature true "aes")
(enableFeature true "md")
(enableFeature false "null")
(enableFeature true "arcfour")
];
NIX_CFLAGS_COMPILE

View File

@ -16,18 +16,13 @@ let
then mkDerivation
else stdenv.mkDerivation;
mkFlag = pfxTrue: pfxFalse: cond: name:
"--${if cond then pfxTrue else pfxFalse}-${name}";
mkEnable = mkFlag "enable" "disable";
mkWith = mkFlag "with" "without";
mkEnablePinentry = f:
enableFeaturePinentry = f:
let
info = flavorInfo.${f};
flag = flavorInfo.${f}.flag or null;
in
optionalString (flag != null)
(mkEnable (elem f enabledFlavors) ("pinentry-" + flag));
(enableFeature (elem f enabledFlavors) ("pinentry-" + flag));
flavorInfo = {
curses = { bin = "curses"; flag = "curses"; buildInputs = [ ncurses ]; };
@ -68,9 +63,9 @@ pinentryMkDerivation rec {
];
configureFlags = [
(mkWith (libcap != null) "libcap")
(mkEnable (libsecret != null) "libsecret")
] ++ (map mkEnablePinentry (attrNames flavorInfo));
(withFeature (libcap != null) "libcap")
(enableFeature (libsecret != null) "libsecret")
] ++ (map enableFeaturePinentry (attrNames flavorInfo));
postInstall =
concatStrings (flip map enabledFlavors (f:

View File

@ -9,9 +9,6 @@
}:
with lib;
let
mkFlag = cond: name: if cond then "--enable-${name}" else "--disable-${name}";
in
stdenv.mkDerivation rec {
pname = "rsyslog";
version = "8.2204.1";
@ -36,72 +33,72 @@ stdenv.mkDerivation rec {
"--sysconfdir=/etc"
"--localstatedir=/var"
"--with-systemdsystemunitdir=\${out}/etc/systemd/system"
(mkFlag true "largefile")
(mkFlag true "regexp")
(mkFlag (libkrb5 != null) "gssapi-krb5")
(mkFlag true "klog")
(mkFlag true "kmsg")
(mkFlag (systemd != null) "imjournal")
(mkFlag true "inet")
(mkFlag (jemalloc != null) "jemalloc")
(mkFlag true "unlimited-select")
(mkFlag false "debug")
(mkFlag false "debug-symbols")
(mkFlag true "debugless")
(mkFlag false "valgrind")
(mkFlag false "diagtools")
(mkFlag true "usertools")
(mkFlag (libmysqlclient != null) "mysql")
(mkFlag (postgresql != null) "pgsql")
(mkFlag (libdbi != null) "libdbi")
(mkFlag (net-snmp != null) "snmp")
(mkFlag (libuuid != null) "uuid")
(mkFlag (curl != null) "elasticsearch")
(mkFlag (gnutls != null) "gnutls")
(mkFlag (libgcrypt != null) "libgcrypt")
(mkFlag true "rsyslogrt")
(mkFlag true "rsyslogd")
(mkFlag true "mail")
(mkFlag (liblognorm != null) "mmnormalize")
(mkFlag (libmaxminddb != null) "mmdblookup")
(mkFlag true "mmjsonparse")
(mkFlag true "mmaudit")
(mkFlag true "mmanon")
(mkFlag true "mmutf8fix")
(mkFlag true "mmcount")
(mkFlag true "mmsequence")
(mkFlag true "mmfields")
(mkFlag true "mmpstrucdata")
(mkFlag (openssl != null) "mmrfc5424addhmac")
(mkFlag (librelp != null) "relp")
(mkFlag (libksi != null) "ksi-ls12")
(mkFlag (liblogging != null) "liblogging-stdlog")
(mkFlag (liblogging != null) "rfc3195")
(mkFlag true "imfile")
(mkFlag false "imsolaris")
(mkFlag true "imptcp")
(mkFlag true "impstats")
(mkFlag true "omprog")
(mkFlag (libnet != null) "omudpspoof")
(mkFlag true "omstdout")
(mkFlag (systemd != null) "omjournal")
(mkFlag true "pmlastmsg")
(mkFlag true "pmcisconames")
(mkFlag true "pmciscoios")
(mkFlag true "pmaixforwardedfrom")
(mkFlag true "pmsnare")
(mkFlag true "omruleset")
(mkFlag true "omuxsock")
(mkFlag true "mmsnmptrapd")
(mkFlag (hadoop != null) "omhdfs")
(mkFlag (rdkafka != null) "omkafka")
(mkFlag (libmongo-client != null) "ommongodb")
(mkFlag (czmq != null) "imczmq")
(mkFlag (czmq != null) "omczmq")
(mkFlag (rabbitmq-c != null) "omrabbitmq")
(mkFlag (hiredis != null) "omhiredis")
(mkFlag (curl != null) "omhttpfs")
(mkFlag true "generate-man-pages")
(enableFeature true "largefile")
(enableFeature true "regexp")
(enableFeature (libkrb5 != null) "gssapi-krb5")
(enableFeature true "klog")
(enableFeature true "kmsg")
(enableFeature (systemd != null) "imjournal")
(enableFeature true "inet")
(enableFeature (jemalloc != null) "jemalloc")
(enableFeature true "unlimited-select")
(enableFeature false "debug")
(enableFeature false "debug-symbols")
(enableFeature true "debugless")
(enableFeature false "valgrind")
(enableFeature false "diagtools")
(enableFeature true "usertools")
(enableFeature (libmysqlclient != null) "mysql")
(enableFeature (postgresql != null) "pgsql")
(enableFeature (libdbi != null) "libdbi")
(enableFeature (net-snmp != null) "snmp")
(enableFeature (libuuid != null) "uuid")
(enableFeature (curl != null) "elasticsearch")
(enableFeature (gnutls != null) "gnutls")
(enableFeature (libgcrypt != null) "libgcrypt")
(enableFeature true "rsyslogrt")
(enableFeature true "rsyslogd")
(enableFeature true "mail")
(enableFeature (liblognorm != null) "mmnormalize")
(enableFeature (libmaxminddb != null) "mmdblookup")
(enableFeature true "mmjsonparse")
(enableFeature true "mmaudit")
(enableFeature true "mmanon")
(enableFeature true "mmutf8fix")
(enableFeature true "mmcount")
(enableFeature true "mmsequence")
(enableFeature true "mmfields")
(enableFeature true "mmpstrucdata")
(enableFeature (openssl != null) "mmrfc5424addhmac")
(enableFeature (librelp != null) "relp")
(enableFeature (libksi != null) "ksi-ls12")
(enableFeature (liblogging != null) "liblogging-stdlog")
(enableFeature (liblogging != null) "rfc3195")
(enableFeature true "imfile")
(enableFeature false "imsolaris")
(enableFeature true "imptcp")
(enableFeature true "impstats")
(enableFeature true "omprog")
(enableFeature (libnet != null) "omudpspoof")
(enableFeature true "omstdout")
(enableFeature (systemd != null) "omjournal")
(enableFeature true "pmlastmsg")
(enableFeature true "pmcisconames")
(enableFeature true "pmciscoios")
(enableFeature true "pmaixforwardedfrom")
(enableFeature true "pmsnare")
(enableFeature true "omruleset")
(enableFeature true "omuxsock")
(enableFeature true "mmsnmptrapd")
(enableFeature (hadoop != null) "omhdfs")
(enableFeature (rdkafka != null) "omkafka")
(enableFeature (libmongo-client != null) "ommongodb")
(enableFeature (czmq != null) "imczmq")
(enableFeature (czmq != null) "omczmq")
(enableFeature (rabbitmq-c != null) "omrabbitmq")
(enableFeature (hiredis != null) "omhiredis")
(enableFeature (curl != null) "omhttpfs")
(enableFeature true "generate-man-pages")
];
passthru.tests = {