3
0
Fork 0
forked from mirrors/nixpkgs

treewide: use optionalString

This commit is contained in:
Felix Buehler 2023-02-06 21:49:02 +01:00
parent 7f610b4d3f
commit cdb39a86e0
118 changed files with 225 additions and 281 deletions

View file

@ -13,7 +13,7 @@ in pkgs.lib.listToAttrs (builtins.map ({ predictable, withNetworkd }: {
name = pkgs.lib.optionalString (!predictable) "un" + "predictable"
+ pkgs.lib.optionalString withNetworkd "Networkd";
value = makeTest {
name = "${if predictable then "" else "un"}predictableInterfaceNames${if withNetworkd then "-with-networkd" else ""}";
name = "${lib.optionalString (!predictable) "un"}predictableInterfaceNames${lib.optionalString withNetworkd "-with-networkd"}";
meta = {};
nodes.machine = { lib, ... }: {

View file

@ -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

View file

@ -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";

View file

@ -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

View file

@ -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 = {

View file

@ -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 ${

View file

@ -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;

View file

@ -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 =
[

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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" ];

View file

@ -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.

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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"}
)
'';

View file

@ -83,12 +83,12 @@ stdenv.mkDerivation {
'' + (if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf" then ''
patchelf --set-soname libblas${canonicalExtension} $out/lib/libblas${canonicalExtension}
patchelf --set-rpath "$(patchelf --print-rpath $out/lib/libblas${canonicalExtension}):${lib.getLib blasProvider'}/lib" $out/lib/libblas${canonicalExtension}
'' else if stdenv.hostPlatform.isDarwin then ''
'' else lib.optionalString (stdenv.hostPlatform.isDarwin) ''
install_name_tool \
-id $out/lib/libblas${canonicalExtension} \
-add_rpath ${lib.getLib blasProvider'}/lib \
$out/lib/libblas${canonicalExtension}
'' else "") + ''
'') + ''
if [ "$out/lib/libblas${canonicalExtension}" != "$out/lib/libblas${stdenv.hostPlatform.extensions.sharedLibrary}" ]; then
ln -s $out/lib/libblas${canonicalExtension} "$out/lib/libblas${stdenv.hostPlatform.extensions.sharedLibrary}"
@ -115,12 +115,12 @@ EOF
'' + (if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf" then ''
patchelf --set-soname libcblas${canonicalExtension} $out/lib/libcblas${canonicalExtension}
patchelf --set-rpath "$(patchelf --print-rpath $out/lib/libcblas${canonicalExtension}):${lib.getLib blasProvider'}/lib" $out/lib/libcblas${canonicalExtension}
'' else if stdenv.hostPlatform.isDarwin then ''
'' else lib.optionalString stdenv.hostPlatform.isDarwin ''
install_name_tool \
-id $out/lib/libcblas${canonicalExtension} \
-add_rpath ${lib.getLib blasProvider'}/lib \
$out/lib/libcblas${canonicalExtension}
'' else "") + ''
'') + ''
if [ "$out/lib/libcblas${canonicalExtension}" != "$out/lib/libcblas${stdenv.hostPlatform.extensions.sharedLibrary}" ]; then
ln -s $out/lib/libcblas${canonicalExtension} "$out/lib/libcblas${stdenv.hostPlatform.extensions.sharedLibrary}"
fi

View file

@ -54,10 +54,10 @@ stdenv.mkDerivation {
cp -L "$liblapack" $out/lib/liblapack${canonicalExtension}
chmod +w $out/lib/liblapack${canonicalExtension}
'' + (if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf" then ''
'' + (lib.optionalString (stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf") ''
patchelf --set-soname liblapack${canonicalExtension} $out/lib/liblapack${canonicalExtension}
patchelf --set-rpath "$(patchelf --print-rpath $out/lib/liblapack${canonicalExtension}):${lapackProvider'}/lib" $out/lib/liblapack${canonicalExtension}
'' else "") + ''
'') + ''
if [ "$out/lib/liblapack${canonicalExtension}" != "$out/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}" ]; then
ln -s $out/lib/liblapack${canonicalExtension} "$out/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}"
@ -83,10 +83,10 @@ EOF
cp -L "$liblapacke" $out/lib/liblapacke${canonicalExtension}
chmod +w $out/lib/liblapacke${canonicalExtension}
'' + (if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf" then ''
'' + (lib.optionalString (stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf") ''
patchelf --set-soname liblapacke${canonicalExtension} $out/lib/liblapacke${canonicalExtension}
patchelf --set-rpath "$(patchelf --print-rpath $out/lib/liblapacke${canonicalExtension}):${lib.getLib lapackProvider'}/lib" $out/lib/liblapacke${canonicalExtension}
'' else "") + ''
'') + ''
if [ -f "$out/lib/liblapacke.so.3" ]; then
ln -s $out/lib/liblapacke.so.3 $out/lib/liblapacke.so

View file

@ -92,9 +92,8 @@ let
else "";
expand-response-params =
if buildPackages ? stdenv && buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null"
then import ../expand-response-params { inherit (buildPackages) stdenv; }
else "";
lib.optionalString (buildPackages ? stdenv && buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null")
(import ../expand-response-params { inherit (buildPackages) stdenv; });
in

View file

@ -118,10 +118,10 @@ stdenv.mkDerivation (fBuildAttrs // {
# Remove all built in external workspaces, Bazel will recreate them when building
rm -rf $bazelOut/external/{bazel_tools,\@bazel_tools.marker}
${if removeRulesCC then "rm -rf $bazelOut/external/{rules_cc,\\@rules_cc.marker}" else ""}
${lib.optionalString removeRulesCC "rm -rf $bazelOut/external/{rules_cc,\\@rules_cc.marker}"}
rm -rf $bazelOut/external/{embedded_jdk,\@embedded_jdk.marker}
${if removeLocalConfigCc then "rm -rf $bazelOut/external/{local_config_cc,\\@local_config_cc.marker}" else ""}
${if removeLocal then "rm -rf $bazelOut/external/{local_*,\\@local_*.marker}" else ""}
${lib.optionalString removeLocalConfigCc "rm -rf $bazelOut/external/{local_config_cc,\\@local_config_cc.marker}"}
${lib.optionalString removeLocal "rm -rf $bazelOut/external/{local_*,\\@local_*.marker}"}
# Clear markers
find $bazelOut/external -name '@*\.marker' -exec sh -c 'echo > {}' \;

View file

@ -212,7 +212,7 @@ in stdenv.mkDerivation {
cd $out
${extraBuildCommands}
cd $out
${if isMultiBuild then extraBuildCommandsMulti else ""}
${lib.optionalString isMultiBuild extraBuildCommandsMulti}
'';
preferLocalBuild = true;
allowSubstitutes = false;

View file

@ -1,4 +1,4 @@
{ stdenv, buildEnv, writeText, pkgs, pkgsi686Linux }:
{ stdenv, lib, buildEnv, writeText, pkgs, pkgsi686Linux }:
{ name
, profile ? ""
@ -237,7 +237,7 @@ in stdenv.mkDerivation {
cd $out
${extraBuildCommands}
cd $out
${if isMultiBuild then extraBuildCommandsMulti else ""}
${lib.optionalString isMultiBuild extraBuildCommandsMulti}
'';
preferLocalBuild = true;
allowSubstitutes = false;

View file

@ -59,9 +59,7 @@ let
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
expand-response-params =
if (buildPackages.stdenv.hasCC or false) && buildPackages.stdenv.cc != "/dev/null"
then import ../expand-response-params { inherit (buildPackages) stdenv; }
else "";
lib.optionalString ((buildPackages.stdenv.hasCC or false) && buildPackages.stdenv.cc != "/dev/null") (import ../expand-response-params { inherit (buildPackages) stdenv; });
useGccForLibs = isClang
&& libcxx == null

View file

@ -35,4 +35,4 @@ let
({prefix, path}: "DOCKER_CREDENTIALS" == prefix)
builtins.nixPath);
in
if (pathParts != []) then (builtins.head pathParts).path else ""
lib.optionalString (pathParts != []) ((builtins.head pathParts).path)

View file

@ -1,9 +1,9 @@
{stdenv, fossil, cacert}:
{stdenv, lib, fossil, cacert}:
{name ? null, url, rev, sha256}:
stdenv.mkDerivation {
name = "fossil-archive" + (if name != null then "-${name}" else "");
name = "fossil-archive" + (lib.optionalString (name != null) "-${name}");
builder = ./builder.sh;
nativeBuildInputs = [fossil cacert];

View file

@ -7,9 +7,7 @@
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null
then "-${short}"
else "";
appendShort = lib.optionalString ((builtins.match "[a-f0-9]*" rev) != null) "-${short}";
in "${if matched == null then base else builtins.head matched}${appendShort}";
in
{ url, rev ? "HEAD", md5 ? "", sha256 ? "", hash ? "", leaveDotGit ? deepClone

View file

@ -12,13 +12,13 @@ if md5 != null then
else
# TODO: statically check if mercurial as the https support if the url starts woth https.
stdenvNoCC.mkDerivation {
name = "hg-archive" + (if name != null then "-${name}" else "");
name = "hg-archive" + (lib.optionalString (name != null) "-${name}");
builder = ./builder.sh;
nativeBuildInputs = [mercurial];
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
subrepoClause = if fetchSubrepos then "S" else "";
subrepoClause = lib.optionalString fetchSubrepos "S";
outputHashAlgo = "sha256";
outputHashMode = "recursive";

View file

@ -18,7 +18,7 @@
let
args' = if relative != null then {
stripLen = 1 + lib.length (lib.splitString "/" relative) + stripLen;
extraPrefix = if extraPrefix != null then extraPrefix else "";
extraPrefix = lib.optionalString (extraPrefix != null) extraPrefix;
} else {
inherit stripLen extraPrefix;
};

View file

@ -36,6 +36,6 @@ stdenvNoCC.mkDerivation {
inherit perl;
inherit (builtins) storeDir;
shell = lib.getBin shell + (shell.shellPath or "");
signingUtils = if darwinCodeSign then signingUtils else "";
signingUtils = lib.optionalString darwinCodeSign signingUtils;
};
}

View file

@ -10,7 +10,7 @@
directory, so the Makefile of the package should support DESTDIR.
*/
{ src, stdenv
{ src, lib, stdenv
, name ? "binary-tarball"
, ... } @ args:
@ -30,7 +30,7 @@ stdenv.mkDerivation (
// args //
{
name = name + (if src ? version then "-" + src.version else "");
name = name + (lib.optionalString (src ? version) "-${src.version}");
postHook = ''
mkdir -p $out/nix-support

View file

@ -24,7 +24,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation (
// removeAttrs args ["vmTools" "lib"] //
{
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
name = name + "-" + diskImage.name + (lib.optionalString (src ? version) "-${src.version}");
# !!! cut&paste from rpm-build.nix
postHook = ''

View file

@ -11,7 +11,7 @@ rec {
makeSourceTarball = sourceTarball; # compatibility
binaryTarball = args: import ./binary-tarball.nix (
{ inherit stdenv;
{ inherit lib stdenv;
} // args);
mvnBuild = args: import ./maven-build.nix (
@ -38,7 +38,7 @@ rec {
} // args);
rpmBuild = args: import ./rpm-build.nix (
{ inherit vmTools;
{ inherit lib vmTools;
} // args);
debBuild = args: import ./debian-build.nix (

View file

@ -22,7 +22,7 @@ in
stdenv.mkDerivation ( {
inherit name src;
phases = "setupPhase unpackPhase patchPhase mvnCompile ${if doTestCompile then "mvnTestCompile mvnTestJar" else ""} ${if doTest then "mvnTest" else ""} ${if doJavadoc then "mvnJavadoc" else ""} ${if doCheckstyle then "mvnCheckstyle" else ""} mvnJar mvnAssembly mvnRelease finalPhase";
phases = "setupPhase unpackPhase patchPhase mvnCompile ${lib.optionalString doTestCompile "mvnTestCompile mvnTestJar"} ${lib.optionalString doTest "mvnTest"} ${lib.optionalString doJavadoc "mvnJavadoc"} ${lib.optionalString doCheckstyle "mvnCheckstyle"} mvnJar mvnAssembly mvnRelease finalPhase";
setupPhase = ''
runHook preSetupPhase
@ -88,9 +88,9 @@ stdenv.mkDerivation ( {
echo "$releaseName" > $out/nix-support/hydra-release-name
${if doRelease then ''
${lib.optionalString doRelease ''
echo "file zip $out/release/$releaseName.zip" >> $out/nix-support/hydra-build-products
'' else ""}
''}
'';
finalPhase = ''

View file

@ -85,7 +85,7 @@ stdenv.mkDerivation (
// removeAttrs args [ "lib" ] # Propagating lib causes the evaluation to fail, because lib is a function that can't be converted to a string
// {
name = name + (if src ? version then "-" + src.version else "");
name = name + (lib.optionalString (src ? version) "-${src.version}");
postHook = ''
. ${./functions.sh}
@ -167,7 +167,7 @@ stdenv.mkDerivation (
echo "building out of source tree, from \`$PWD'..."
${if preConfigure != null then preConfigure else ""}
${lib.optionalString (preConfigure != null) preConfigure}
'';
}
else {})

View file

@ -3,7 +3,7 @@
{ name ? "rpm-build"
, diskImage
, src, vmTools
, src, lib, vmTools
, ... } @ args:
vmTools.buildRPM (
@ -11,7 +11,7 @@ vmTools.buildRPM (
removeAttrs args ["vmTools"] //
{
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
name = name + "-" + diskImage.name + (lib.optionalString (src ? version) "-${src.version}");
preBuild = ''
. ${./functions.sh}

View file

@ -299,7 +299,7 @@ crate_: lib.makeOverridable
);
libName = if crate ? libName then crate.libName else crate.crateName;
libPath = if crate ? libPath then crate.libPath else "";
libPath = lib.optionalString (crate ? libPath) crate.libPath;
# Seed the symbol hashes with something unique every time.
# https://doc.rust-lang.org/1.0.0/rustc/metadata/loader/index.html#frobbing-symbols

View file

@ -406,7 +406,7 @@ rec {
eval "$origPostHook"
'';
origPostHook = if attrs ? postHook then attrs.postHook else "";
origPostHook = lib.optionalString (attrs ? postHook) attrs.postHook;
/* Don't run Nix-specific build steps like patchelf. */
fixupPhase = "true";

View file

@ -186,10 +186,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -207,8 +207,8 @@ stdenv.mkDerivation ({
''
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
))
)
else "")
+ lib.optionalString targetPlatform.isAvr ''
makeFlagsArray+=(
'-s' # workaround for hitting hydra log limit

View file

@ -195,10 +195,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -216,8 +216,8 @@ stdenv.mkDerivation ({
''
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
))
)
else "")
+ lib.optionalString targetPlatform.isAvr ''
makeFlagsArray+=(
'-s' # workaround for hitting hydra log limit

View file

@ -226,10 +226,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -248,7 +248,7 @@ stdenv.mkDerivation ({
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
)
else "")
))
+ lib.optionalString targetPlatform.isAvr ''
makeFlagsArray+=(
'-s' # workaround for hitting hydra log limit

View file

@ -246,10 +246,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -267,8 +267,8 @@ stdenv.mkDerivation ({
''
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
)
else "");
))
);
inherit noSysDirs staticCompiler langJava crossStageStatic
libcCross crossMingw;

View file

@ -190,10 +190,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -211,8 +211,8 @@ stdenv.mkDerivation ({
''
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
))
)
else "")
+ lib.optionalString targetPlatform.isAvr ''
makeFlagsArray+=(
'LIMITS_H_TEST=false'

View file

@ -172,10 +172,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -193,8 +193,8 @@ stdenv.mkDerivation ({
''
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
))
)
else "")
+ lib.optionalString targetPlatform.isAvr ''
makeFlagsArray+=(
'LIMITS_H_TEST=false'

View file

@ -186,10 +186,10 @@ stdenv.mkDerivation ({
--replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname"
''
+ (
if targetPlatform != hostPlatform || stdenv.cc.libc != null then
lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null)
# On NixOS, use the right path to the dynamic linker instead of
# `/lib/ld*.so'.
let
(let
libc = if libcCross != null then libcCross else stdenv.cc.libc;
in
(
@ -207,8 +207,8 @@ stdenv.mkDerivation ({
''
sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
''
))
)
else "")
+ lib.optionalString targetPlatform.isAvr ''
makeFlagsArray+=(
'LIMITS_H_TEST=false'

View file

@ -155,12 +155,12 @@ stdenv.mkDerivation rec {
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
'' else lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
rm -rf bin/*_*
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''}
'' else "");
'');
installPhase = ''
runHook preInstall

View file

@ -155,12 +155,12 @@ stdenv.mkDerivation rec {
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
'' else lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
rm -rf bin/*_*
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''}
'' else "");
'');
installPhase = ''
runHook preInstall

View file

@ -147,12 +147,12 @@ stdenv.mkDerivation rec {
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH}
''}
'' else if (stdenv.hostPlatform != stdenv.targetPlatform) then ''
'' else lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
rm -rf bin/*_*
${lib.optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) ''
rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH}
''}
'' else "");
'');
installPhase = ''
runHook preInstall

View file

@ -79,8 +79,8 @@ openjdk17.overrideAttrs (oldAttrs: rec {
installPhase = let
buildType = if debugBuild then "fastdebug" else "release";
debugSuffix = if debugBuild then "-fastdebug" else "";
jcefSuffix = if debugBuild then "" else "_jcef";
debugSuffix = lib.optionalString debugBuild "-fastdebug";
jcefSuffix = lib.optionalString (!debugBuild) "_jcef";
in ''
runHook preInstall

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
{ lib, runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -1,10 +1,7 @@
{ runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
prefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
in runCommand "llvm-binutils-${version}" {
preferLocalBuild = true;
passthru = {

View file

@ -188,7 +188,7 @@ stdenv.mkDerivation rec {
lib.concatStringsSep " "
(builtins.map (x: "--with-${x}") enableFeatures ++
builtins.map (x: "--without-${x}") disableFeatures)
} ${if stdenv.hostPlatform.system == "aarch64-darwin" then "--arch=arm64" else ""}
} ${lib.optionalString (stdenv.hostPlatform.system == "aarch64-darwin") "--arch=arm64"}
(cd doc/manual ; make info)
runHook postBuild

View file

@ -96,7 +96,7 @@ let
for i in ./scripts/*.sh ./scripts/*.py ./test/*.sh ./test/*.py; do
patchShebangs "$i"
done
TERM=xterm ./scripts/tests.sh ${if z3Support then "--no-smt" else ""}
TERM=xterm ./scripts/tests.sh ${lib.optionalString z3Support "--no-smt"}
popd
'';

View file

@ -16,8 +16,7 @@ stdenv.mkDerivation (swift._wrapperParams // {
swiftOs swiftArch
swiftModuleSubdir swiftLibSubdir
swiftStaticModuleSubdir swiftStaticLibSubdir;
swiftDriver = if useSwiftDriver
then "${swift-driver}/bin/swift-driver" else "";
swiftDriver = lib.optionalString useSwiftDriver "${swift-driver}/bin/swift-driver";
passAsFile = [ "buildCommand" ];
buildCommand = ''

View file

@ -254,7 +254,7 @@ in package-set { inherit pkgs lib callPackage; } self // {
# a cabal flag with '--flag=myflag'.
developPackage =
{ root
, name ? if builtins.typeOf root == "path" then builtins.baseNameOf root else ""
, name ? lib.optionalString (builtins.typeOf root == "path") (builtins.baseNameOf root)
, source-overrides ? {}
, overrides ? self: super: {}
, modifier ? drv: drv

View file

@ -10,9 +10,8 @@ let
let
version = pkg.version or "";
in
if isPvpVersion version then
''"${name}","${version}","http://hydra.nixos.org/job/nixpkgs/trunk/haskellPackages.${name}.x86_64-linux"''
else "";
lib.optionalString (isPvpVersion version)
''"${name}","${version}","http://hydra.nixos.org/job/nixpkgs/trunk/haskellPackages.${name}.x86_64-linux"'';
all-haskellPackages = builtins.toFile "all-haskellPackages" (lib.concatStringsSep "\n" (lib.filter (x: x != "") (lib.mapAttrsToList pkgLine haskellPackages)));
in
runCommand "hackage-package-list" { }

View file

@ -19,7 +19,7 @@ lib.makePackageOverridable
name = "dhall-directory-package.nix";
buildCommand = ''
dhall-to-nixpkgs directory --fixed-output-derivations --file "${file}" "${src}" ${if document then "--document" else ""} > $out
dhall-to-nixpkgs directory --fixed-output-derivations --file "${file}" "${src}" ${lib.optionalString document "--document"} > $out
'';
nativeBuildInputs = [ dhall-nixpkgs ];

View file

@ -186,7 +186,7 @@ let
NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-lobjc";
# See https://savannah.gnu.org/bugs/?50339
F77_INTEGER_8_FLAG = if use64BitIdx then "-fdefault-integer-8" else "";
F77_INTEGER_8_FLAG = lib.optionalString use64BitIdx "-fdefault-integer-8";
configureFlags = [
"--with-blas=blas"

View file

@ -26,7 +26,7 @@ let
inherit self sourceVersion pythonVersion packageOverrides;
implementation = "pypy";
libPrefix = "pypy${pythonVersion}";
executable = "pypy${if isPy39OrNewer then lib.versions.majorMinor pythonVersion else if isPy3k then "3" else ""}";
executable = "pypy${if isPy39OrNewer then lib.versions.majorMinor pythonVersion else lib.optionalString isPy3k "3"}";
sitePackages = "site-packages";
hasDistutilsCxxPatch = false;
inherit pythonAttr;

View file

@ -32,7 +32,7 @@ let
inherit self sourceVersion pythonVersion packageOverrides;
implementation = "pypy";
libPrefix = "pypy${pythonVersion}";
executable = "pypy${if isPy3k then "3" else ""}";
executable = "pypy${lib.optionalString isPy3k "3"}";
sitePackages = "lib/${libPrefix}/site-packages";
hasDistutilsCxxPatch = false;

View file

@ -32,7 +32,7 @@ let
inherit self sourceVersion pythonVersion packageOverrides;
implementation = "pypy";
libPrefix = "pypy${pythonVersion}";
executable = "pypy${if isPy3k then "3" else ""}";
executable = "pypy${lib.optionalString isPy3k "3"}";
sitePackages = "site-packages";
hasDistutilsCxxPatch = false;

View file

@ -55,9 +55,9 @@ let
self.majMinTiny + (
if self.patchLevel != null then
"-p${self.patchLevel}"
else if self.tail != "" then
"-${self.tail}"
else "");
else
lib.optionalString (self.tail != "") "-${self.tail}"
);
};
in
rubyVersion

View file

@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
++ lib.optionals stdenv.isDarwin [ CoreServices Security ];
configurePhase = ''
python configure.py --prefix=$out --with-bzip2 --with-zlib ${extraConfigureFlags}${if stdenv.cc.isClang then " --cc=clang" else "" }
python configure.py --prefix=$out --with-bzip2 --with-zlib ${extraConfigureFlags}${lib.optionalString stdenv.cc.isClang " --cc=clang"}
'';
enableParallelBuilding = true;

View file

@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
preCheck = ''
${if stdenv.isDarwin then "export DYLD_LIBRARY_PATH=$(pwd)/src/" else "export LD_LIBRARY_PATH=$(pwd)/src/"}
${if enablePython then "sed -i -e 's|^#!.*|#!${stdenv.shell}|' python/py.test.sh" else ""}
${lib.optionalString enablePython "sed -i -e 's|^#!.*|#!${stdenv.shell}|' python/py.test.sh"}
'';
cmakeFlags = lib.optionals enablePython [

View file

@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
hardeningDisable = [ "format" ];
LDFLAGS = if stdenv.isSunOS then "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec" else "";
LDFLAGS = lib.optionalString stdenv.isSunOS "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec";
configureFlags = [
"--disable-csharp" "--with-xz"

View file

@ -169,7 +169,7 @@ stdenv.mkDerivation ({
buildInputs = [ linuxHeaders ] ++ lib.optionals withGd [ gd libpng ] ++ extraBuildInputs;
env = {
linuxHeaders = if withLinuxHeaders then linuxHeaders else "";
linuxHeaders = lib.optionalString withLinuxHeaders linuxHeaders;
inherit (stdenv) is64bit;
# Needed to install share/zoneinfo/zone.tab. Set to impure /bin/sh to
# prevent a retained dependency on the bootstrap tools in the stdenv-linux

View file

@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
(lib.enableFeature frontendSupport "dynamic-frontends")
#(enableFeature mp3xSupport "mp3x")
(lib.enableFeature mp3rtpSupport "mp3rtp")
(if debugSupport then "--enable-debug=alot" else "")
(lib.optionalString debugSupport "--enable-debug=alot")
];
preConfigure = ''

View file

@ -269,7 +269,7 @@ stdenv.mkDerivation rec {
(cfg "runstatedir" "/run")
(cfg "init_script" (if isDarwin then "none" else "systemd"))
(cfg "qemu_datadir" (if isDarwin then "${qemu}/share/qemu" else ""))
(cfg "qemu_datadir" (lib.optionalString isDarwin "${qemu}/share/qemu"))
(feat "apparmor" isLinux)
(feat "attr" isLinux)

View file

@ -156,7 +156,7 @@ stdenv.mkDerivation rec {
else if stdenv.hostPlatform.osxMinVersion == "10.5" then "9"
else "8"
else ""}-gcc"
(if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
(lib.optionalString stdenv.hostPlatform.isCygwin "--enable-static-msvcrt")
] # Experimental features
++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"

View file

@ -165,7 +165,7 @@ stdenv.mkDerivation rec {
experimentalEmulateHardwareSupport) "experimental")
] ++ optionals (stdenv.isBSD || stdenv.hostPlatform != stdenv.buildPlatform) [
"--force-target=${stdenv.hostPlatform.parsed.cpu.name}-${kernel}-gcc"
(if stdenv.hostPlatform.isCygwin then "--enable-static-msvcrt" else "")
(lib.optionalString stdenv.hostPlatform.isCygwin "--enable-static-msvcrt")
] # Experimental features
++ optional experimentalSpatialSvcSupport "--enable-spatial-svc"
++ optional experimentalFpMbStatsSupport "--enable-fp-mb-stats"

View file

@ -21,10 +21,10 @@ stdenv.mkDerivation rec {
preConfigure = ''
substituteInPlace src/Makefile.in \
--replace "-L\$(subst /libgfortran.a, ,\$(FRTLIB) )" "-L${gfortran.cc.lib}/lib"
'' + (if stdenv.isDarwin then ''
'' + (lib.optionalString stdenv.isDarwin ''
substituteInPlace src/Makefile.in \
--replace "gfortran -print-file-name=libgfortran.a" "gfortran -print-file-name=libgfortran.dylib"
'' else "");
'');
enableParallelBuilding = false; # broken

View file

@ -16,7 +16,7 @@
}:
let
threadingSuffix = if withOpenMP then "-mt" else "";
threadingSuffix = lib.optionalString withOpenMP "-mt";
blasIntSize = if blas64 then "64" else "32";
in stdenv.mkDerivation rec {
pname = "amd-blis";

View file

@ -5,7 +5,7 @@
}:
let
dbg = if debugEnable then "-dbg" else "";
dbg = lib.optionalString debugEnable "-dbg";
debugEnable = p4est-sc-debugEnable;
mpiSupport = p4est-sc-mpiSupport;
isOpenmpi = mpiSupport && mpi.pname == "openmpi";
@ -35,7 +35,7 @@ stdenv.mkDerivation {
'';
preConfigure = ''
echo "2.8.0" > .tarball-version
${if mpiSupport then "unset CC" else ""}
${lib.optionalString mpiSupport "unset CC"}
'';
configureFlags = [ "--enable-pthread=-pthread" ]

View file

@ -9,7 +9,7 @@
let
inherit (p4est-sc) debugEnable mpiSupport;
dbg = if debugEnable then "-dbg" else "";
dbg = lib.optionalString debugEnable "-dbg";
withMetis = p4est-withMetis;
in
stdenv.mkDerivation {

View file

@ -55,11 +55,11 @@ stdenv.mkDerivation rec {
"--with-fc=mpif90"
"--with-mpi=1"
''}
${if withp4est then ''
${lib.optionalString withp4est ''
"--with-p4est=1"
"--with-zlib-include=${zlib.dev}/include"
"--with-zlib-lib=-L${zlib}/lib -lz"
'' else ""}
''}
"--with-blas=1"
"--with-lapack=1"
)

View file

@ -19,14 +19,10 @@ stdenv.mkDerivation rec {
# udns uses a very custom build and hardcodes a .so name in a few places.
# Instead of fighting with it to apply the standard dylib script, change
# the right place in the Makefile itself.
postPatch =
if stdenv.isDarwin
then
''
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace Makefile.in \
--replace --soname, -install_name,$out/lib/
''
else "";
'';
installPhase = ''
runHook preInstall

View file

@ -167,7 +167,7 @@ stdenv.mkDerivation ({
echo "file binary-dist \"$(ls $out/*.apk)\"" > $out/nix-support/hydra-build-products
''
else if target == "iphone" then
if release then ''
lib.optionalString release ''
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.ipa)\"" > $out/nix-support/hydra-build-products
@ -180,7 +180,6 @@ stdenv.mkDerivation ({
echo "doc install \"$out/$appname.html\"" >> $out/nix-support/hydra-build-products
''}
''
else ""
else throw "Target: ${target} is not supported!"}
'';

View file

@ -103,10 +103,9 @@ stdenv.mkDerivation {
''
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 android/titanium_prep.linux32
''
else if stdenv.system == "x86_64-linux" then
''
else lib.optionalString (stdenv.system == "x86_64-linux") ''
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 android/titanium_prep.linux64
''
else ""}
}
'';
}

View file

@ -105,10 +105,9 @@ stdenv.mkDerivation {
''
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 android/titanium_prep.linux32
''
else if stdenv.system == "x86_64-linux" then
''
else lib.optionalString (stdenv.system == "x86_64-linux") ''
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 android/titanium_prep.linux64
''
else ""}
}
'';
}

View file

@ -91,7 +91,7 @@ stdenv.mkDerivation ({
# Do the building
export LD=/usr/bin/clang # To avoid problem with -isysroot parameter that is unrecognized by the stock ld. Comparison with an impure build shows that it uses clang instead. Ugly, but it works
xcodebuild -target ${_target} -configuration ${_configuration} ${lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateIPA || generateXCArchive then "-archivePath \"${name}.xcarchive\" archive" else ""} ${if release then '' PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"'' else ""} ${xcodeFlags}
xcodebuild -target ${_target} -configuration ${_configuration} ${lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${lib.optionalString (generateIPA || generateXCArchive) "-archivePath \"${name}.xcarchive\" archive"} ${lib.optionalString release '' PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"''} ${xcodeFlags}
${lib.optionalString release ''
${lib.optionalString generateIPA ''

View file

@ -268,11 +268,7 @@ final: prev: {
nativeBuildInputs = [ pkgs.buildPackages.makeWrapper ];
postFixup = ''
wrapProgram "$out/bin/makam" --prefix PATH : ${lib.makeBinPath [ nodejs ]}
${
if stdenv.isLinux
then "patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 \"$out/lib/node_modules/makam/makam-bin-linux64\""
else ""
}
${lib.optionalString stdenv.isLinux "patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 \"$out/lib/node_modules/makam/makam-bin-linux64\""}
'';
};

View file

@ -46,7 +46,7 @@ in buildPythonPackage rec {
${lib.optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"}
'';
preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
preBuild = lib.optionalString mpiSupport "export CC=${mpi}/bin/mpicc";
nativeBuildInputs = [
cython

View file

@ -70,10 +70,10 @@ buildPythonPackage rec {
typing
];
configurePhase = if !(pythonOlder "3.5") then ''
configurePhase = lib.optionalString (! pythonOlder "3.5") ''
substituteInPlace setup.py \
--replace "'typing'," ""
'' else "";
'';
checkPhase = ''
pytest --ignore tests/test_cli.py \

View file

@ -75,7 +75,7 @@ let
tfFeature = x: if x then "1" else "0";
version = "2.11.0";
variant = if cudaSupport then "-gpu" else "";
variant = lib.optionalString cudaSupport "-gpu";
pname = "tensorflow${variant}";
pythonEnv = python.withPackages (_:

View file

@ -66,9 +66,8 @@ let
name;
copyIfBundledByPath = { bundledByPath ? false, ...}:
(if bundledByPath then
assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/" #*/
else ""
(lib.optionalString bundledByPath (
assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/") #*/
);
maybeCopyAll = pkgname: if pkgname == null then "" else

View file

@ -27,10 +27,10 @@ let
CXXFLAGS="-O2 -fno-strict-aliasing"
--mandir=$out/share/man
${if sysconfDir == "" then "" else "--sysconfdir=${sysconfDir}"}
${if static then "LDFLAGS=-static" else ""}
--with${if static == true || popt == null then "" else "out"}-included-popt
--with${if avahi != null then "" else "out"}-avahi
--with${if gtk3 != null then "" else "out"}-gtk
${lib.optionalString static "LDFLAGS=-static"}
${lib.withFeature (static == true || popt == null) "included-popt"}
${lib.withFeature (avahi != null) "avahi"}
${lib.withFeature (gtk3 != null) "gtk"}
--without-gnome
--enable-rfc2553
--disable-Werror # a must on gcc 4.6

View file

@ -151,7 +151,7 @@ let
(builtins.filter
({ prefix, path }: "NETRC" == prefix)
builtins.nixPath);
netrc_file = if (pathParts != [ ]) then (builtins.head pathParts).path else "";
netrc_file = lib.optionalString (pathParts != [ ]) (builtins.head pathParts).path;
in
pkgs.runCommand file
{

View file

@ -457,9 +457,9 @@ lib.composeManyExtensions [
preConfigure = lib.concatStringsSep "\n" [
(old.preConfigure or "")
(if (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11" && stdenv.isDarwin) then ''
(lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11" && stdenv.isDarwin) ''
MACOSX_DEPLOYMENT_TARGET=10.16
'' else "")
'')
];
preBuild = old.preBuild or "" + ''
@ -720,7 +720,7 @@ lib.composeManyExtensions [
(old.propagatedBuildInputs or [ ])
++ lib.optionals mpiSupport [ self.mpi4py self.openssh ]
;
preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
preBuild = lib.optionalString mpiSupport "export CC=${mpi}/bin/mpicc";
HDF5_DIR = "${pkgs.hdf5}";
HDF5_MPI = if mpiSupport then "ON" else "OFF";
# avoid strict pinning of numpy

View file

@ -202,7 +202,7 @@ let
--run "$out/share/factorio/update-config.sh" \
--argv0 "" \
--add-flags "-c \$HOME/.factorio/config.cfg" \
${if mods!=[] then "--add-flags --mod-directory=${modDir}" else ""}
${lib.optionalString (mods!=[]) "--add-flags --mod-directory=${modDir}"}
# TODO Currently, every time a mod is changed/added/removed using the
# modlist, a new derivation will take up the entire footprint of the

View file

@ -14,8 +14,7 @@ stdenv.mkDerivation {
fetchurl { inherit url sha256; };
shell = stdenv.shell;
arch = if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
else if stdenv.hostPlatform.system == "i686-linux" then "x86"
else "";
else lib.optionalString (stdenv.hostPlatform.system == "i686-linux") "x86";
unpackPhase = ''
mkdir oilrush
cd oilrush

View file

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
wrapGAppsHook
];
NIX_CFLAGS_COMPILE = if isMobile then "-DSTYLUS_BASED" else "";
NIX_CFLAGS_COMPILE = lib.optionalString isMobile "-DSTYLUS_BASED";
buildInputs = [ gtk3 libX11 ];

View file

@ -23,7 +23,7 @@
# to see what will break when upgrading. Consider a new versioned attribute.
let
installationPath = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64" else "i386";
appendPath = if stdenv.hostPlatform.system == "x86_64-linux" then "64" else "";
appendPath = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "64";
libPath = lib.makeLibraryPath [ cups libusb-compat-0_1 ] + ":$out/lib:${stdenv.cc.cc.lib}/lib${appendPath}";
in stdenv.mkDerivation rec {
pname = "samsung-UnifiedLinuxDriver";

Some files were not shown because too many files have changed in this diff Show more