Skip to content

Commit cdb39a8

Browse files
committed
treewide: use optionalString
1 parent 7f610b4 commit cdb39a8

118 files changed

Lines changed: 225 additions & 281 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

nixos/tests/predictable-interface-names.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ in pkgs.lib.listToAttrs (builtins.map ({ predictable, withNetworkd }: {
1313
name = pkgs.lib.optionalString (!predictable) "un" + "predictable"
1414
+ pkgs.lib.optionalString withNetworkd "Networkd";
1515
value = makeTest {
16-
name = "${if predictable then "" else "un"}predictableInterfaceNames${if withNetworkd then "-with-networkd" else ""}";
16+
name = "${lib.optionalString (!predictable) "un"}predictableInterfaceNames${lib.optionalString withNetworkd "-with-networkd"}";
1717
meta = {};
1818

1919
nodes.machine = { lib, ... }: {

pkgs/applications/audio/espeak/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ stdenv.mkDerivation rec {
1919
prePatch = ''
2020
sed -e s,/bin/ln,ln,g -i src/Makefile
2121
sed -e 's,^CXXFLAGS=-O2,CXXFLAGS=-O2 -D PATH_ESPEAK_DATA=\\\"$(DATADIR)\\\",' -i src/Makefile
22-
'' + (if portaudio.api_version == 19 then ''
22+
'' + (lib.optionalString (portaudio.api_version == 19) ''
2323
cp src/portaudio19.h src/portaudio.h
24-
'' else "");
24+
'');
2525

2626
configurePhase = ''
2727
cd src

pkgs/applications/audio/musly/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ stdenv.mkDerivation {
1010
};
1111
nativeBuildInputs = [ cmake ];
1212
buildInputs = [ eigen ffmpeg ];
13-
fixupPhase = if stdenv.isDarwin then ''
13+
fixupPhase = lib.optionalString stdenv.isDarwin ''
1414
install_name_tool -change libmusly.dylib $out/lib/libmusly.dylib $out/bin/musly
1515
install_name_tool -change libmusly_resample.dylib $out/lib/libmusly_resample.dylib $out/bin/musly
1616
install_name_tool -change libmusly_resample.dylib $out/lib/libmusly_resample.dylib $out/lib/libmusly.dylib
17-
'' else "";
17+
'';
1818

1919
meta = with lib; {
2020
homepage = "https://www.musly.org";

pkgs/applications/display-managers/lightdm-tiny-greeter/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ stdenv.mkDerivation rec {
1515
nativeBuildInputs = [ pkg-config wrapGAppsHook ];
1616
buildInputs = [ lightdm gtk3 glib ];
1717

18-
postUnpack = if conf != "" then ''
18+
postUnpack = lib.optionalString (conf != "") ''
1919
cp ${builtins.toFile "config.h" conf} source/config.h
20-
'' else "";
20+
'';
2121

2222
buildPhase = ''
2323
mkdir -p $out/bin $out/share/xgreeters

pkgs/applications/editors/texmacs/common.nix

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ rec {
2727

2828
postPatch = (if tex == null then ''
2929
gunzip < ${fullFontsSrc} | (cd TeXmacs && tar xvf -)
30-
'' else if extraFonts then ''
30+
'' else lib.optionalString extraFonts ''
3131
gunzip < ${extraFontsSrc} | (cd TeXmacs && tar xvf -)
32-
'' else "") +
33-
(if chineseFonts then ''
32+
'') +
33+
(lib.optionalString chineseFonts ''
3434
gunzip < ${chineseFontsSrc} | (cd TeXmacs && tar xvf -)
35-
'' else "") +
36-
(if japaneseFonts then ''
35+
'') +
36+
(lib.optionalString japaneseFonts ''
3737
gunzip < ${japaneseFontsSrc} | (cd TeXmacs && tar xvf -)
38-
'' else "") +
39-
(if koreanFonts then ''
38+
'') +
39+
(lib.optionalString koreanFonts ''
4040
gunzip < ${koreanFontsSrc} | (cd TeXmacs && tar xvf -)
41-
'' else "");
41+
'');
4242

4343

4444
meta = {

pkgs/applications/editors/vim/plugins/vim-utils.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ rec {
317317
lib.warnIf (wrapManual != null) ''
318318
vim.customize: wrapManual is deprecated: the manual is now included by default if `name == "vim"`.
319319
${if wrapManual == true && name != "vim" then "Set `standalone = false` to include the manual."
320-
else if wrapManual == false && name == "vim" then "Set `standalone = true` to get the *vim wrappers only."
321-
else ""}''
320+
else lib.optionalString (wrapManual == false && name == "vim") "Set `standalone = true` to get the *vim wrappers only."
321+
}''
322322
lib.warnIf (wrapGui != null)
323323
"vim.customize: wrapGui is deprecated: gvim is now automatically included if present"
324324
lib.throwIfNot (vimExecutableName == null && gvimExecutableName == null)
@@ -330,7 +330,7 @@ rec {
330330
else throw "at least one of vimrcConfig and vimrcFile must be specified";
331331
bin = runCommand "${name}-bin" { nativeBuildInputs = [ makeWrapper ]; } ''
332332
vimrc=${lib.escapeShellArg vimrc}
333-
gvimrc=${if gvimrcFile != null then lib.escapeShellArg gvimrcFile else ""}
333+
gvimrc=${lib.optionalString (gvimrcFile != null) (lib.escapeShellArg gvimrcFile)}
334334
335335
mkdir -p "$out/bin"
336336
for exe in ${

pkgs/applications/file-managers/vifm/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ in stdenv.mkDerivation rec {
3434

3535
wrapVifmMedia = "wrapProgram $out/share/vifm/vifm-media --prefix PATH : ${path}";
3636
in ''
37-
${if mediaSupport then wrapVifmMedia else ""}
37+
${lib.optionalString mediaSupport wrapVifmMedia}
3838
'';
3939

4040
meta = with lib; {
41-
description = "A vi-like file manager${if isFullPackage then "; Includes support for optional features" else ""}";
41+
description = "A vi-like file manager${lib.optionalString isFullPackage "; Includes support for optional features"}";
4242
maintainers = with maintainers; [ raskin ];
4343
platforms = if mediaSupport then platforms.linux else platforms.unix;
4444
license = licenses.gpl2;

pkgs/applications/misc/blender/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ stdenv.mkDerivation rec {
8787
'' else ''
8888
substituteInPlace extern/clew/src/clew.c --replace '"libOpenCL.so"' '"${ocl-icd}/lib/libOpenCL.so"'
8989
'') +
90-
(if hipSupport then ''
90+
(lib.optionalString hipSupport ''
9191
substituteInPlace extern/hipew/src/hipew.c --replace '"/opt/rocm/hip/lib/libamdhip64.so"' '"${hip}/lib/libamdhip64.so"'
9292
substituteInPlace extern/hipew/src/hipew.c --replace '"opt/rocm/hip/bin"' '"${hip}/bin"'
93-
'' else "");
93+
'');
9494

9595
cmakeFlags =
9696
[

pkgs/applications/networking/browsers/firefox-bin/update.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ in writeScript "update-${pname}" ''
4646
grep "^[0-9]" | \
4747
sort --version-sort | \
4848
grep -v "funnelcake" | \
49-
grep -e "${if isBeta then "b" else ""}\([[:digit:]]\|[[:digit:]][[:digit:]]\)$" | ${if isBeta then "" else "grep -v \"b\" |"} \
49+
grep -e "${lib.optionalString isBeta "b"}\([[:digit:]]\|[[:digit:]][[:digit:]]\)$" | ${lib.optionalString (not isBeta) "grep -v \"b\" |"} \
5050
tail -1`
5151
5252
curl --silent -o $HOME/shasums "$url$version/SHA256SUMS"

pkgs/applications/networking/browsers/google-chrome/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ let
7070
++ lib.optional libvaSupport libva
7171
++ [ gtk3 ];
7272

73-
suffix = if channel != "stable" then "-" + channel else "";
73+
suffix = lib.optionalString (channel != "stable") "-${channel}";
7474

7575
crashpadHandlerBinary = if lib.versionAtLeast version "94"
7676
then "chrome_crashpad_handler"

0 commit comments

Comments
 (0)