diff options
author | Felix Buehler <account@buehler.rocks> | 2023-02-06 21:49:02 +0100 |
---|---|---|
committer | Felix Buehler <account@buehler.rocks> | 2023-02-13 21:52:34 +0100 |
commit | cdb39a86e0dd7cda3a057f4f4795485a5c9b9be5 (patch) | |
tree | 1fef6e55f39dab2289b68b68972ee4c9b89520f7 /pkgs/applications | |
parent | 7f610b4d3f6e6f695b1f5521862066c0ece79a5a (diff) |
treewide: use optionalString
Diffstat (limited to 'pkgs/applications')
16 files changed, 37 insertions, 38 deletions
diff --git a/pkgs/applications/audio/espeak/default.nix b/pkgs/applications/audio/espeak/default.nix index 2c59068720d08..7164cb5fd3e0c 100644 --- a/pkgs/applications/audio/espeak/default.nix +++ b/pkgs/applications/audio/espeak/default.nix @@ -19,9 +19,9 @@ stdenv.mkDerivation rec { prePatch = '' sed -e s,/bin/ln,ln,g -i src/Makefile sed -e 's,^CXXFLAGS=-O2,CXXFLAGS=-O2 -D PATH_ESPEAK_DATA=\\\"$(DATADIR)\\\",' -i src/Makefile - '' + (if portaudio.api_version == 19 then '' + '' + (lib.optionalString (portaudio.api_version == 19) '' cp src/portaudio19.h src/portaudio.h - '' else ""); + ''); configurePhase = '' cd src diff --git a/pkgs/applications/audio/musly/default.nix b/pkgs/applications/audio/musly/default.nix index 0d10b55d32964..470d5c1050753 100644 --- a/pkgs/applications/audio/musly/default.nix +++ b/pkgs/applications/audio/musly/default.nix @@ -10,11 +10,11 @@ stdenv.mkDerivation { }; nativeBuildInputs = [ cmake ]; buildInputs = [ eigen ffmpeg ]; - fixupPhase = if stdenv.isDarwin then '' + fixupPhase = lib.optionalString stdenv.isDarwin '' install_name_tool -change libmusly.dylib $out/lib/libmusly.dylib $out/bin/musly install_name_tool -change libmusly_resample.dylib $out/lib/libmusly_resample.dylib $out/bin/musly install_name_tool -change libmusly_resample.dylib $out/lib/libmusly_resample.dylib $out/lib/libmusly.dylib - '' else ""; + ''; meta = with lib; { homepage = "https://www.musly.org"; diff --git a/pkgs/applications/display-managers/lightdm-tiny-greeter/default.nix b/pkgs/applications/display-managers/lightdm-tiny-greeter/default.nix index 5c2a6d7c59b04..53f004c2a3671 100644 --- a/pkgs/applications/display-managers/lightdm-tiny-greeter/default.nix +++ b/pkgs/applications/display-managers/lightdm-tiny-greeter/default.nix @@ -15,9 +15,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkg-config wrapGAppsHook ]; buildInputs = [ lightdm gtk3 glib ]; - postUnpack = if conf != "" then '' + postUnpack = lib.optionalString (conf != "") '' cp ${builtins.toFile "config.h" conf} source/config.h - '' else ""; + ''; buildPhase = '' mkdir -p $out/bin $out/share/xgreeters diff --git a/pkgs/applications/editors/texmacs/common.nix b/pkgs/applications/editors/texmacs/common.nix index e52d95f837df4..82dd13920b026 100644 --- a/pkgs/applications/editors/texmacs/common.nix +++ b/pkgs/applications/editors/texmacs/common.nix @@ -27,18 +27,18 @@ rec { postPatch = (if tex == null then '' gunzip < ${fullFontsSrc} | (cd TeXmacs && tar xvf -) - '' else if extraFonts then '' + '' else lib.optionalString extraFonts '' gunzip < ${extraFontsSrc} | (cd TeXmacs && tar xvf -) - '' else "") + - (if chineseFonts then '' + '') + + (lib.optionalString chineseFonts '' gunzip < ${chineseFontsSrc} | (cd TeXmacs && tar xvf -) - '' else "") + - (if japaneseFonts then '' + '') + + (lib.optionalString japaneseFonts '' gunzip < ${japaneseFontsSrc} | (cd TeXmacs && tar xvf -) - '' else "") + - (if koreanFonts then '' + '') + + (lib.optionalString koreanFonts '' gunzip < ${koreanFontsSrc} | (cd TeXmacs && tar xvf -) - '' else ""); + ''); meta = { diff --git a/pkgs/applications/editors/vim/plugins/vim-utils.nix b/pkgs/applications/editors/vim/plugins/vim-utils.nix index 4235aa5e929e0..74c811c2eae8e 100644 --- a/pkgs/applications/editors/vim/plugins/vim-utils.nix +++ b/pkgs/applications/editors/vim/plugins/vim-utils.nix @@ -317,8 +317,8 @@ rec { lib.warnIf (wrapManual != null) '' vim.customize: wrapManual is deprecated: the manual is now included by default if `name == "vim"`. ${if wrapManual == true && name != "vim" then "Set `standalone = false` to include the manual." - else if wrapManual == false && name == "vim" then "Set `standalone = true` to get the *vim wrappers only." - else ""}'' + else lib.optionalString (wrapManual == false && name == "vim") "Set `standalone = true` to get the *vim wrappers only." + }'' lib.warnIf (wrapGui != null) "vim.customize: wrapGui is deprecated: gvim is now automatically included if present" lib.throwIfNot (vimExecutableName == null && gvimExecutableName == null) @@ -330,7 +330,7 @@ rec { else throw "at least one of vimrcConfig and vimrcFile must be specified"; bin = runCommand "${name}-bin" { nativeBuildInputs = [ makeWrapper ]; } '' vimrc=${lib.escapeShellArg vimrc} - gvimrc=${if gvimrcFile != null then lib.escapeShellArg gvimrcFile else ""} + gvimrc=${lib.optionalString (gvimrcFile != null) (lib.escapeShellArg gvimrcFile)} mkdir -p "$out/bin" for exe in ${ diff --git a/pkgs/applications/file-managers/vifm/default.nix b/pkgs/applications/file-managers/vifm/default.nix index 55a7ebd84afcd..ab7da2deac897 100644 --- a/pkgs/applications/file-managers/vifm/default.nix +++ b/pkgs/applications/file-managers/vifm/default.nix @@ -34,11 +34,11 @@ in stdenv.mkDerivation rec { wrapVifmMedia = "wrapProgram $out/share/vifm/vifm-media --prefix PATH : ${path}"; in '' - ${if mediaSupport then wrapVifmMedia else ""} + ${lib.optionalString mediaSupport wrapVifmMedia} ''; meta = with lib; { - description = "A vi-like file manager${if isFullPackage then "; Includes support for optional features" else ""}"; + description = "A vi-like file manager${lib.optionalString isFullPackage "; Includes support for optional features"}"; maintainers = with maintainers; [ raskin ]; platforms = if mediaSupport then platforms.linux else platforms.unix; license = licenses.gpl2; diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 429097842630a..9bb2a11b7cd78 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -87,10 +87,10 @@ stdenv.mkDerivation rec { '' else '' substituteInPlace extern/clew/src/clew.c --replace '"libOpenCL.so"' '"${ocl-icd}/lib/libOpenCL.so"' '') + - (if hipSupport then '' + (lib.optionalString hipSupport '' substituteInPlace extern/hipew/src/hipew.c --replace '"/opt/rocm/hip/lib/libamdhip64.so"' '"${hip}/lib/libamdhip64.so"' substituteInPlace extern/hipew/src/hipew.c --replace '"opt/rocm/hip/bin"' '"${hip}/bin"' - '' else ""); + ''); cmakeFlags = [ diff --git a/pkgs/applications/networking/browsers/firefox-bin/update.nix b/pkgs/applications/networking/browsers/firefox-bin/update.nix index e5284c4097c9d..f7fe34cb8d089 100644 --- a/pkgs/applications/networking/browsers/firefox-bin/update.nix +++ b/pkgs/applications/networking/browsers/firefox-bin/update.nix @@ -46,7 +46,7 @@ in writeScript "update-${pname}" '' grep "^[0-9]" | \ sort --version-sort | \ grep -v "funnelcake" | \ - grep -e "${if isBeta then "b" else ""}\([[:digit:]]\|[[:digit:]][[:digit:]]\)$" | ${if isBeta then "" else "grep -v \"b\" |"} \ + grep -e "${lib.optionalString isBeta "b"}\([[:digit:]]\|[[:digit:]][[:digit:]]\)$" | ${lib.optionalString (not isBeta) "grep -v \"b\" |"} \ tail -1` curl --silent -o $HOME/shasums "$url$version/SHA256SUMS" diff --git a/pkgs/applications/networking/browsers/google-chrome/default.nix b/pkgs/applications/networking/browsers/google-chrome/default.nix index 01cd54cf8ee20..208bff18e1f2b 100644 --- a/pkgs/applications/networking/browsers/google-chrome/default.nix +++ b/pkgs/applications/networking/browsers/google-chrome/default.nix @@ -70,7 +70,7 @@ let ++ lib.optional libvaSupport libva ++ [ gtk3 ]; - suffix = if channel != "stable" then "-" + channel else ""; + suffix = lib.optionalString (channel != "stable") "-${channel}"; crashpadHandlerBinary = if lib.versionAtLeast version "94" then "chrome_crashpad_handler" diff --git a/pkgs/applications/science/biology/plink-ng/default.nix b/pkgs/applications/science/biology/plink-ng/default.nix index b21ef2d71d6c2..00fd0ff0083e0 100644 --- a/pkgs/applications/science/biology/plink-ng/default.nix +++ b/pkgs/applications/science/biology/plink-ng/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { preBuild = '' sed -i 's|zlib-1.2.8/zlib.h|zlib.h|g' *.c *.h - ${if stdenv.cc.isClang then "sed -i 's|g++|clang++|g' Makefile.std" else ""} + ${lib.optionalString stdenv.cc.isClang "sed -i 's|g++|clang++|g' Makefile.std"} makeFlagsArray+=( ZLIB=-lz diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index d7250db07b491..83d696ec52b1a 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -76,11 +76,10 @@ stdenv.mkDerivation rec { # tagged releases don't have "unknown" # kicad nightlies use git describe --dirty # nix removes .git, so its approximated here - postPatch = if (!stable) then '' + postPatch = lib.optionalString (!stable) '' substituteInPlace cmake/KiCadVersion.cmake \ --replace "unknown" "${builtins.substring 0 10 src.rev}" - '' - else ""; + ''; makeFlags = optionals (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ]; diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 9765d2fcc1e42..047484fd9fffa 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -214,7 +214,7 @@ stdenv.mkDerivation rec { description = (if (stable) then "Open Source Electronics Design Automation suite" else "Open Source EDA suite, development build") - + (if (!with3d) then ", without 3D models" else ""); + + (lib.optionalString (!with3d) ", without 3D models"); homepage = "https://www.kicad.org/"; longDescription = '' KiCad is an open source software suite for Electronic Design Automation. diff --git a/pkgs/applications/science/logic/coq/default.nix b/pkgs/applications/science/logic/coq/default.nix index 10d77885b5cb9..49c9fc47fef26 100644 --- a/pkgs/applications/science/logic/coq/default.nix +++ b/pkgs/applications/science/logic/coq/default.nix @@ -66,10 +66,10 @@ let buildIde = args.buildIde or (!coqAtLeast "8.14"); ideFlags = optionalString (buildIde && !coqAtLeast "8.10") "-lablgtkdir ${ocamlPackages.lablgtk}/lib/ocaml/*/site-lib/lablgtk2 -coqide opt"; - csdpPatch = if csdp != null then '' + csdpPatch = lib.optionalString (csdp != null) '' substituteInPlace plugins/micromega/sos.ml --replace "; csdp" "; ${csdp}/bin/csdp" substituteInPlace plugins/micromega/coq_micromega.ml --replace "System.is_in_system_path \"csdp\"" "true" - '' else ""; + ''; ocamlPackages = if !isNull customOCamlPackages then customOCamlPackages else with versions; switch coq-version [ { case = range "8.16" "8.17"; out = ocamlPackages_4_14; } @@ -158,7 +158,7 @@ self = stdenv.mkDerivation { UNAME=$(type -tp uname) RM=$(type -tp rm) substituteInPlace tools/beautify-archive --replace "/bin/rm" "$RM" - ${if !coqAtLeast "8.7" then "substituteInPlace configure.ml --replace \"md5 -q\" \"md5sum\"" else ""} + ${lib.optionalString (!coqAtLeast "8.7") "substituteInPlace configure.ml --replace \"md5 -q\" \"md5sum\""} ${csdpPatch} ''; @@ -196,7 +196,7 @@ self = stdenv.mkDerivation { categories = [ "Development" "Science" "Math" "IDE" "GTK" ]; }); - postInstall = let suffix = if coqAtLeast "8.14" then "-core" else ""; in optionalString (!coqAtLeast "8.17") '' + postInstall = let suffix = optionalString (coqAtLeast "8.14") "-core"; in optionalString (!coqAtLeast "8.17") '' cp bin/votour $out/bin/ '' + '' ln -s $out/lib/coq${suffix} $OCAMLFIND_DESTDIR/coq${suffix} @@ -227,12 +227,12 @@ if coqAtLeast "8.17" then self.overrideAttrs(_: { buildPhase = '' runHook preBuild make dunestrap - dune build -p coq-core,coq-stdlib,coq,coqide-server${if buildIde then ",coqide" else ""} -j $NIX_BUILD_CORES + dune build -p coq-core,coq-stdlib,coq,coqide-server${lib.optionalString buildIde ",coqide"} -j $NIX_BUILD_CORES runHook postBuild ''; installPhase = '' runHook preInstall - dune install --prefix $out coq-core coq-stdlib coq coqide-server${if buildIde then " coqide" else ""} + dune install --prefix $out coq-core coq-stdlib coq coqide-server${lib.optionalString buildIde " coqide"} runHook postInstall ''; }) else self diff --git a/pkgs/applications/science/math/sage/sage-tests.nix b/pkgs/applications/science/math/sage/sage-tests.nix index 79d4f78082e09..4910f5e8bf1d2 100644 --- a/pkgs/applications/science/math/sage/sage-tests.nix +++ b/pkgs/applications/science/math/sage/sage-tests.nix @@ -18,7 +18,7 @@ let src = sage-with-env.env.lib.src; runAllTests = files == null; testArgs = if runAllTests then "--all" else testFileList; - patienceSpecifier = if longTests then "--long" else ""; + patienceSpecifier = lib.optionalString longTests "--long"; timeSpecifier = if timeLimit == null then "" else "--short ${toString timeLimit}"; relpathToArg = relpath: lib.escapeShellArg "${src}/${relpath}"; # paths need to be absolute testFileList = lib.concatStringsSep " " (map relpathToArg files); diff --git a/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix b/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix index 088fa83b7d92e..ffa0a158ac95a 100644 --- a/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix +++ b/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix @@ -16,7 +16,7 @@ let # getAttr-like helper for optional append to string: # "Hello" + appendByAttr "a" " " {a = "world";} = "Hello world" # "Hello" + appendByAttr "a" " " {} = "Hello" - appendByAttr = attr: sep: x: if hasAttr attr x then sep + (getAttr attr x) else ""; + appendByAttr = attr: sep: x: lib.optionalString (hasAttr attr x) (sep + (getAttr attr x)); # Are there any OM dependencies at all? ifDeps = length pkg.omdeps != 0; diff --git a/pkgs/applications/window-managers/dwl/default.nix b/pkgs/applications/window-managers/dwl/default.nix index 251092049c9ae..6e2e45e8b9a67 100644 --- a/pkgs/applications/window-managers/dwl/default.nix +++ b/pkgs/applications/window-managers/dwl/default.nix @@ -63,8 +63,8 @@ stdenv.mkDerivation (self: { preBuild = '' makeFlagsArray+=( - XWAYLAND=${if enableXWayland then "-DXWAYLAND" else ""} - XLIBS=${if enableXWayland then "xcb\\ xcb-icccm" else ""} + XWAYLAND=${lib.optionalString enableXWayland "-DXWAYLAND"} + XLIBS=${lib.optionalString enableXWayland "xcb\\ xcb-icccm"} ) ''; |