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

View file

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

View file

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

View file

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

View file

@ -7,13 +7,6 @@
with lib; with lib;
let 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; shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optLz4 = shouldUsePkg lz4; optLz4 = shouldUsePkg lz4;
@ -39,19 +32,19 @@ stdenv.mkDerivation rec {
buildInputs = [ optLz4 optSnappy optZlib optBzip2 optDb optGperftools optLeveldb ]; buildInputs = [ optLz4 optSnappy optZlib optBzip2 optDb optGperftools optLeveldb ];
configureFlags = [ configureFlags = [
(mkWith false "attach" null) (withFeature false "attach")
(mkWith true "builtins" "") (withFeatureAs true "builtins" "")
(mkEnable (optBzip2 != null) "bzip2" null) (enableFeature (optBzip2 != null) "bzip2")
(mkEnable false "diagnostic" null) (enableFeature false "diagnostic")
(mkEnable false "java" null) (enableFeature false "java")
(mkEnable (optLeveldb != null) "leveldb" null) (enableFeature (optLeveldb != null) "leveldb")
(mkEnable false "python" null) (enableFeature false "python")
(mkEnable (optSnappy != null) "snappy" null) (enableFeature (optSnappy != null) "snappy")
(mkEnable (optLz4 != null) "lz4" null) (enableFeature (optLz4 != null) "lz4")
(mkEnable (optGperftools != null) "tcmalloc" null) (enableFeature (optGperftools != null) "tcmalloc")
(mkEnable (optZlib != null) "zlib" null) (enableFeature (optZlib != null) "zlib")
(mkWith (optDb != null) "berkeleydb" optDb) (withFeatureAs (optDb != null) "berkeleydb" optDb)
(mkWith false "helium" null) (withFeature false "helium")
]; ];
preConfigure = '' preConfigure = ''

View file

@ -6,14 +6,6 @@
}: }:
let 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; shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
optPam = shouldUsePkg pam; optPam = shouldUsePkg pam;
@ -37,19 +29,19 @@ stdenv.mkDerivation rec {
buildInputs = [ libgcrypt libgpg-error libtasn1 optPam optLibidn optGnutls ]; buildInputs = [ libgcrypt libgpg-error libtasn1 optPam optLibidn optGnutls ];
configureFlags = [ configureFlags = [
(mkOther "sysconfdir" "/etc") "--sysconfdir=/etc"
(mkOther "localstatedir" "/var") "--localstatedir=/var"
(mkEnable true "libgcrypt" null) (enableFeature true "libgcrypt")
(mkEnable (optPam != null) "pam" null) (enableFeature (optPam != null) "pam")
(mkEnable true "ipv6" null) (enableFeature true "ipv6")
(mkWith (optLibidn != null) "stringprep" null) (withFeature (optLibidn != null) "stringprep")
(mkEnable (optGnutls != null) "starttls" null) (enableFeature (optGnutls != null) "starttls")
(mkEnable true "des" null) (enableFeature true "des")
(mkEnable true "3des" null) (enableFeature true "3des")
(mkEnable true "aes" null) (enableFeature true "aes")
(mkEnable true "md" null) (enableFeature true "md")
(mkEnable false "null" null) (enableFeature false "null")
(mkEnable true "arcfour" null) (enableFeature true "arcfour")
]; ];
NIX_CFLAGS_COMPILE NIX_CFLAGS_COMPILE

View file

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

View file

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