Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: improve prepending and appending derivation arguments in bash code #357052

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pkgs/applications/audio/fmit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ mkDerivation rec {
substituteInPlace fmit.pro --replace '$$FMITVERSIONGITPRO' '${version}'
'';

preConfigure = ''
qmakeFlags="$qmakeFlags \
CONFIG+=${lib.optionalString alsaSupport "acs_alsa"} \
CONFIG+=${lib.optionalString jackSupport "acs_jack"} \
CONFIG+=${lib.optionalString portaudioSupport "acs_portaudio"} \
PREFIXSHORTCUT=$out"
'';
qmakeFlags = [
"PREFIXSHORTCUT=${placeholder "out"}"
] ++ lib.optionals alsaSupport [
"CONFIG+=acs_alsa"
] ++ lib.optionals jackSupport [
"CONFIG+=acs_jack"
] ++ lib.optionals portaudioSupport [
"CONFIG+=acs_portaudio"
];

meta = with lib; {
description = "Free Musical Instrument Tuner";
Expand Down
4 changes: 1 addition & 3 deletions pkgs/applications/audio/sonic-pi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ stdenv.mkDerivation rec {
"-DUSE_SYSTEM_LIBS=ON"
"-DBUILD_IMGUI_INTERFACE=${if withImGui then "ON" else "OFF"}"
"-DWITH_QT_GUI_WEBENGINE=${if withTauWidget then "ON" else "OFF"}"
"-DAPP_INSTALL_ROOT=${placeholder "out"}/app"
];

doCheck = true;
Expand Down Expand Up @@ -136,9 +137,6 @@ stdenv.mkDerivation rec {

# Prebuild Ruby vendored dependencies and Qt docs
./linux-prebuild.sh -o

# Append CMake flag depending on the value of $out
cmakeFlags+=" -DAPP_INSTALL_ROOT=$out/app"
'';

postBuild = ''
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/kde/marble.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkDerivation {
protobuf_21 qtscript qtsvg qtquickcontrols qtwebengine shared-mime-info krunner kparts
knewstuff gpsd
];
preConfigure = ''
cmakeFlags+=" -DINCLUDE_INSTALL_DIR=''${!outputDev}/include"
wolfgangwalther marked this conversation as resolved.
Show resolved Hide resolved
'';
cmakeFlags = [
"-DINCLUDE_INSTALL_DIR=${placeholder "dev"}/include"
];
}
6 changes: 3 additions & 3 deletions pkgs/applications/misc/maliit-framework/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ mkDerivation rec {
wayland-scanner
];

preConfigure = ''
cmakeFlags+="-DQT5_PLUGINS_INSTALL_DIR=$out/$qtPluginPrefix"
'';
cmakeFlags = [
"-DQT5_PLUGINS_INSTALL_DIR=${placeholder "out"}/$qtPluginPrefix"
];

meta = with lib; {
description = "Core libraries of Maliit and server";
Expand Down
6 changes: 4 additions & 2 deletions pkgs/applications/science/misc/boinc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ stdenv.mkDerivation rec {

preConfigure = ''
./_autosetup
configureFlags="$configureFlags --sysconfdir=$out/etc"
'';

enableParallelBuilding = true;

configureFlags = [ "--disable-server" ] ++ lib.optionals headless [ "--disable-manager" ];
configureFlags = [
"--disable-server"
"--sysconfdir=${placeholder "out"}/etc"
] ++ lib.optionals headless [ "--disable-manager" ];

postInstall = ''
install --mode=444 -D 'client/scripts/boinc-client.service' "$out/etc/systemd/system/boinc.service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
];

preConfigure = ''
configureFlags="$configureFlags --with-lablgtk-dir=$(echo ${lablgtk}/lib/ocaml/*/site-lib/lablgtk2)"
appendToVar configureFlags "--with-lablgtk-dir=$(echo ${lablgtk}/lib/ocaml/*/site-lib/lablgtk2)"
'';

postInstall = ''
Expand Down
5 changes: 4 additions & 1 deletion pkgs/applications/version-management/vcprompt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ stdenv.mkDerivation rec {

preConfigure = ''
autoconf
makeFlags="$makeFlags PREFIX=$out"
'';

makeFlags = [
"PREFIX=${placeholder "out"}"
];

meta = with lib; {
description = ''
A little C program that prints a short string with barebones information
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/video/kodi/unwrapped.nix
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ in stdenv.mkDerivation (finalAttrs: {
# Need these tools on the build system when cross compiling,
# hacky, but have found no other way.
CXX=$CXX_FOR_BUILD LD=ld make -C tools/depends/native/JsonSchemaBuilder
cmakeFlags+=" -DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
appendToVar cmakeFlags "-DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"

CXX=$CXX_FOR_BUILD LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
cmakeFlags+=" -DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
appendToVar cmakeFlags "-DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
'';

postPatch = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/release/binary-tarball.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ stdenv.mkDerivation (

# Prefix hackery because of a bug in stdenv (it tries to `mkdir
# $prefix', which doesn't work due to the DESTDIR).
configureFlags="--prefix=$prefix $configureFlags"
prependToVar configureFlags "--prefix=$prefix"
dontAddPrefix=1
prefix=$TMPDIR/inst$prefix
'';
Expand Down
5 changes: 4 additions & 1 deletion pkgs/by-name/cl/cl-launch/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ stdenv.mkDerivation rec {
};

preConfigure = ''
export makeFlags="$makeFlags PREFIX='$out'"
mkdir -p "$out/bin"
'';

makeFlags = [
"PREFIX=${placeholder "out"}"
];

preBuild = ''
sed -e 's/\t\t@/\t\t/g' -i Makefile
'';
Expand Down
4 changes: 1 addition & 3 deletions pkgs/by-name/fl/fluxus/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ stdenv.mkDerivation {
"RacketInclude=${racket}/include/racket"
"RacketLib=${racket}/lib/racket"
"DESTDIR=build"
"Prefix=${placeholder "out"}"
];
configurePhase = ''
sconsFlags+=" Prefix=$out"
'';
installPhase = ''
mkdir -p $out
cp -r build$out/* $out/
Expand Down
10 changes: 5 additions & 5 deletions pkgs/by-name/gl/globulation2/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ scons ];
buildInputs = [ libGLU libGL SDL SDL_ttf SDL_image zlib SDL_net speex libvorbis libogg boost fribidi bsdiff ];

postConfigure = ''
sconsFlags+=" BINDIR=$out/bin"
sconsFlags+=" INSTALLDIR=$out/share/globulation2"
sconsFlags+=" DATADIR=$out/share/globulation2/glob2"
'';
sconsFlags = [
"BINDIR=${placeholder "out"}/bin"
"INSTALLDIR=${placeholder "out"}/share/globulation2"
"DATADIR=${placeholder "out"}/share/globulation2/glob2"
];

NIX_LDFLAGS = "-lboost_system";

Expand Down
5 changes: 2 additions & 3 deletions pkgs/by-name/gp/gpsd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ stdenv.mkDerivation rec {
sed -e "s|systemd_dir = .*|systemd_dir = '$out/lib/systemd/system'|" -i SConscript
export TAR=noop
substituteInPlace SConscript --replace "env['CCVERSION']" "env['CC']"

sconsFlags+=" udevdir=$out/lib/udev"
sconsFlags+=" python_libdir=$out/${python3Packages.python.sitePackages}"
'';

# - leapfetch=no disables going online at build time to fetch leap-seconds
Expand All @@ -102,6 +99,8 @@ stdenv.mkDerivation rec {
"gpsd_group=${gpsdGroup}"
"systemd=yes"
"xgps=${if guiSupport then "True" else "False"}"
"udevdir=${placeholder "out"}/lib/udev"
"python_libdir=${placeholder "out"}/${python3Packages.python.sitePackages}"
];

preCheck = ''
Expand Down
6 changes: 3 additions & 3 deletions pkgs/by-name/gt/gt5/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ stdenv.mkDerivation rec {
sed 's/-o root -g root//' -i Makefile
'';

preConfigure = ''
makeFlags="$makeFlags PREFIX=$out"
'';
makeFlags = [
"PREFIX=${placeholder "out"}"
];

meta = {
description = "Diff-capable 'du' browser";
Expand Down
5 changes: 4 additions & 1 deletion pkgs/by-name/lx/lxdvdrip/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ stdenv.mkDerivation rec {
postPatch = ''
sed -i -e s,/usr/local,$out, -e s,/etc,$out/etc,g Makefile
sed -i -e s,/usr/local,$out, mbuffer/Makefile
makeFlags="$makeFlags PREFIX=$out"
'';

makeFlags = [
"PREFIX=${placeholder "out"}"
];

preInstall = ''
mkdir -p $out/man/man1 $out/bin $out/share $out/etc
'';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/ne/netcdfcxx4/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
];

preConfigure = ''
cmakeFlags+="-Dabs_top_srcdir=$(readlink -f ./)"
appendToVar cmakeFlags "-Dabs_top_srcdir=$(readlink -f ./)"
'';

nativeBuildInputs = [ cmake ninja ];
Expand Down
5 changes: 2 additions & 3 deletions pkgs/by-name/nf/nfs-utils/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ stdenv.mkDerivation rec {
'';

configureFlags =
[ "--enable-gss"
[ "--with-start-statd=${placeholder "out"}/bin/start-statd"
"--enable-gss"
"--enable-svcgss"
"--with-statedir=/var/lib/nfs"
"--with-krb5=${lib.getLib libkrb5}"
Expand All @@ -67,8 +68,6 @@ stdenv.mkDerivation rec {
sed -i "s,/usr/sbin,$out/bin,g" utils/statd/statd.c
sed -i "s,^PATH=.*,PATH=$out/bin:${statdPath}," utils/statd/start-statd

configureFlags="--with-start-statd=$out/bin/start-statd $configureFlags"

substituteInPlace systemd/nfs-utils.service \
--replace "/bin/true" "${coreutils}/bin/true"

Expand Down
3 changes: 2 additions & 1 deletion pkgs/by-name/np/np2kai/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ stdenv.mkDerivation rec {

configurePhase = ''
export GIT_VERSION=${builtins.substring 0 7 src.rev}
buildFlags="$buildFlags ''${enableParallelBuilding:+-j$NIX_BUILD_CORES}"
'' + optionalString enableParallelBuilding ''
appendToVar buildFlags "-j$NIX_BUILD_CORES"
'' + optionalString enableX11 ''
cd x11
substituteInPlace Makefile.am \
Expand Down
6 changes: 4 additions & 2 deletions pkgs/by-name/pa/pacparser/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ stdenv.mkDerivation rec {
sha256 = "sha256-X842+xPjM404aQJTc2JwqU4vq8kgyKhpnqVu70pNLks=";
};

makeFlags = [ "NO_INTERNET=1" ];
makeFlags = [
"NO_INTERNET=1"
"PREFIX=${placeholder "out"}"
];

preConfigure = ''
export makeFlags="$makeFlags PREFIX=$out"
patchShebangs tests/runtests.sh
cd src
'';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/pa/patchPpdFilesHook/patch-ppd-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ patchPpdFileCommands () {
# The end result might contain too many
# propagated dependencies for multi-output packages,
# but never a broken package.
propagatedBuildInputs+=("$path")
appendToVar propagatedBuildInputs "$path"
done < sorted-dependencies
fi

Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/pu/pulseaudio-module-xrdp/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
mv pulseaudio-* pulseaudio-src
chmod +w -Rv pulseaudio-src
cp ${pulseaudio.dev}/include/pulse/config.h pulseaudio-src
configureFlags="$configureFlags PULSE_DIR=$(realpath ./pulseaudio-src)"
appendToVar configureFlags "PULSE_DIR=$(realpath ./pulseaudio-src)"
'';

installPhase = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/ro/rocksndiamonds/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stdenv.mkDerivation rec {

preBuild = ''
dataDir="$out/share/rocksndiamonds"
makeFlags+="BASE_PATH=$dataDir"
appendToVar makeFlags "BASE_PATH=$dataDir"
'';

installPhase = ''
Expand Down
12 changes: 6 additions & 6 deletions pkgs/by-name/rt/rt/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ stdenv.mkDerivation rec {
echo rt-${version} > .tag
'';
preConfigure = ''
configureFlags="$configureFlags --with-web-user=$UID"
configureFlags="$configureFlags --with-web-group=$(id -g)"
configureFlags="$configureFlags --with-rt-group=$(id -g)"
configureFlags="$configureFlags --with-bin-owner=$UID"
configureFlags="$configureFlags --with-libs-owner=$UID"
configureFlags="$configureFlags --with-libs-group=$(id -g)"
appendToVar configureFlags "--with-web-user=$UID"
appendToVar configureFlags "--with-web-group=$(id -g)"
appendToVar configureFlags "--with-rt-group=$(id -g)"
appendToVar configureFlags "--with-bin-owner=$UID"
appendToVar configureFlags "--with-libs-owner=$UID"
appendToVar configureFlags "--with-libs-group=$(id -g)"
'';
configureFlags = [
"--enable-graphviz"
Expand Down
12 changes: 6 additions & 6 deletions pkgs/by-name/se/serf/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ stdenv.mkDerivation rec {
prefixKey = "PREFIX=";

preConfigure = ''
sconsFlags+=" APR=$(echo ${apr.dev}/bin/*-config)"
sconsFlags+=" APU=$(echo ${aprutil.dev}/bin/*-config)"
sconsFlags+=" CC=$CC"
sconsFlags+=" OPENSSL=${openssl}"
sconsFlags+=" ZLIB=${zlib}"
appendToVar sconsFlags "APR=$(echo ${apr.dev}/bin/*-config)"
appendToVar sconsFlags "APU=$(echo ${aprutil.dev}/bin/*-config)"
appendToVar sconsFlags "CC=$CC"
appendToVar sconsFlags "OPENSSL=${openssl}"
appendToVar sconsFlags "ZLIB=${zlib}"
'' + lib.optionalString (!stdenv.hostPlatform.isCygwin) ''
sconsFlags+=" GSSAPI=${libkrb5.dev}"
appendToVar sconsFlags "GSSAPI=${libkrb5.dev}"
'';

enableParallelBuilding = true;
Expand Down
10 changes: 5 additions & 5 deletions pkgs/by-name/si/silc_client/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ stdenv.mkDerivation rec {

hardeningDisable = [ "format" ];

configureFlags = [ "--with-ncurses=${ncurses.dev}" ];

preConfigure = lib.optionalString enablePlugin ''
configureFlags="$configureFlags --with-silc-plugin=$out/lib/irssi"
'';
configureFlags = [
"--with-ncurses=${ncurses.dev}"
] ++ lib.optionals enablePlugin [
"--with-silc-plugin=${placeholder "out"}/lib/irssi"
];

nativeBuildInputs = [ pkg-config ];
buildInputs = [ perl glib ncurses ];
Expand Down
5 changes: 1 addition & 4 deletions pkgs/by-name/sp/spaceFM/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ stdenv.mkDerivation rec {

configureFlags = [
"--with-bash-path=${pkgs.bash}/bin/bash"
"--sysconfdir=${placeholder "out"}/etc"
];

preConfigure = ''
configureFlags="$configureFlags --sysconfdir=$out/etc"
'';

postInstall = ''
rm -f $out/etc/spacefm/spacefm.conf
ln -s /etc/spacefm/spacefm.conf $out/etc/spacefm/spacefm.conf
Expand Down
5 changes: 4 additions & 1 deletion pkgs/by-name/tr/trigger/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ stdenv.mkDerivation rec {

sed s,lSDL2main,lSDL2, -i GNUmakefile
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${SDL2.dev}/include/SDL2"
export makeFlags="$makeFlags prefix=$out"
'';

makeFlags = [
"prefix=${placeholder "out"}"
];

enableParallelBuilding = true;

postInstall = ''
Expand Down
5 changes: 4 additions & 1 deletion pkgs/by-name/ts/tsocks/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ stdenv.mkDerivation rec {
preConfigure = ''
sed -i -e "s,\\\/usr,"$(echo $out|sed -e "s,\\/,\\\\\\\/,g")",g" tsocks
substituteInPlace tsocks --replace /usr $out
export configureFlags="$configureFlags --libdir=$out/lib"
'';

configureFlags = [
"--libdir=${placeholder "out"}/lib"
];

preBuild = ''
# We don't need the saveme binary, it is in fact never stored and we're
# never injecting stuff into ld.so.preload anyway
Expand Down
Loading