Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cbbe29d
glibcLocales: move to env
globin Oct 27, 2023
57ea81b
glibc: move to env
globin Aug 2, 2023
46bb0e6
glibc: improve makeFlags handling
globin Oct 27, 2023
052a91e
pkg-config-wrapper: move to env
globin Aug 2, 2023
0cdaf48
write-mirror-list: fix with __structuredAttrs
globin Oct 27, 2023
3d113ab
add-opengl-runpath: substituteAll needs env
globin Aug 4, 2023
1bc26c2
substituteAll: fix with structuredAttrs
globin Oct 28, 2023
9b7d21a
autoreconf: fix with __structuredAttrs
globin Oct 27, 2023
d9f77ab
remove-references-to: substituteAll needs env
globin Aug 4, 2023
d3a39f9
libtirpc: use env
globin Aug 4, 2023
44216e8
libkrb5: fix shell quoting
globin Aug 4, 2023
c2414bb
unbound: fix for structuredAttrs
globin Aug 4, 2023
c1133be
perl-packages: fix with __structuredAttrs
WilliButz Sep 10, 2023
8167da6
perlPackages: fix with structuredAttrs
globin Aug 2, 2023
0694655
gcc12: move to env
globin Aug 2, 2023
9737144
gcc: fix env for non-native builds
Ma27 Sep 9, 2023
a7c549b
fftw: fix with __structuredAttrs
globin Sep 9, 2023
56398b4
python setup hooks: fix with structuredAttrs
globin Aug 2, 2023
1c87596
python.pkgs.pytest-asyncio: move to env
globin Aug 2, 2023
c40f958
meson: fix with structuredAttrs
globin Oct 28, 2023
b228798
buildEnv: use structuredAttrs
globin Aug 3, 2023
6054d14
substituteAll: don't pass `meta` to `env`
Ma27 Sep 9, 2023
7a283a0
substituteAll: correctly expose meta; pre/postInstall doesn't need to…
Ma27 Sep 10, 2023
1547b55
mkDerivation: also allow isPath in env
globin Oct 28, 2023
4292e6e
kbd: move to env
globin Oct 29, 2023
d0a0544
pytest-check-hook: fix with structuredAttrs
globin Aug 3, 2023
2db732b
python3.pkgs.psutil: $out is no longer interpolated
globin Aug 3, 2023
4ecf01b
cmake: fix for structured-attrs
globin Aug 4, 2023
fe8cbf0
libbpf: fix makeFlags with structuredAttrs
globin Sep 8, 2023
f958ebd
buildPythonPackage: fix disabledTestPaths
globin Aug 4, 2023
1b8bc56
pystemmer: move to env
globin Aug 2, 2023
ef9749a
xorg.*: fix for structuredAttrs
globin Aug 4, 2023
835db15
python.pkgs.pkgconfig: fix with __structuredAttrs
globin Sep 9, 2023
078fcf3
python3.pkgs.platformdirs: use env
globin Aug 4, 2023
fe043ee
python.pkgs.pytest-xdist: fix with structuredAttrs
globin Sep 9, 2023
e5fe90b
wrapPythonPrograms: fix with __structuredAttrs
globin Oct 30, 2023
e2b5918
python-dbusmock: fix with __structuredAttrs
globin Oct 30, 2023
1c3bd66
polkit: use env
globin Sep 9, 2023
7236644
ffmpeg: fix with __structuredAttrs
globin Sep 9, 2023
874bd05
scons: fix with __structuredAttrs
globin Sep 9, 2023
3e62118
qt5.qtbase: fix with __structuredAttrs
globin Sep 9, 2023
599747a
qtbase: fix nesting of lists in configureFlags
lheckemann Sep 10, 2023
c1a0395
qt5.*: fix hooks with __structuredAttrs
globin Sep 9, 2023
a0e9200
rustfmt: use env
globin Sep 9, 2023
7b973a5
mesa: fix with __structuredAttrs
globin Sep 10, 2023
eb6b8b6
rust-bindgen: fix with __structuredAttrs
globin Sep 9, 2023
9617bc0
symlinkJoin: fix with __structuredAttrs
globin Sep 10, 2023
51d005c
hspell: fix with __structuredAttrs
globin Sep 9, 2023
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
2 changes: 1 addition & 1 deletion pkgs/build-support/add-opengl-runpath/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
stdenv.mkDerivation {
name = "add-opengl-runpath";

driverLink = "/run/opengl-driver" + lib.optionalString stdenv.isi686 "-32";
env.driverLink = "/run/opengl-driver" + lib.optionalString stdenv.isi686 "-32";

buildCommand = ''
mkdir -p $out/nix-support
Expand Down
32 changes: 13 additions & 19 deletions pkgs/build-support/buildenv/builder.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
$SIG{__WARN__} = sub { warn "warning: ", @_ };
$SIG{__DIE__} = sub { die "error: ", @_ };

my $out = $ENV{"out"};
my $extraPrefix = $ENV{"extraPrefix"};
open my $fh, '<', '.attrs.json' or die "Can't open file $!";
my $attrsJson = do { local $/; <$fh> };
close $fh;

my @pathsToLink = split ' ', $ENV{"pathsToLink"};
my $nixAttrs = decode_json($attrsJson);
my $out = $nixAttrs->{outputs}->{out};
my $extraPrefix = $nixAttrs->{extraPrefix};

my @pathsToLink = @{$nixAttrs->{pathsToLink}};

sub isInPathsToLink {
my $path = shift;
Expand Down Expand Up @@ -218,24 +223,13 @@ sub addPkg {
}
}

# Read packages list.
my $pkgs;

if (exists $ENV{"pkgsPath"}) {
open FILE, $ENV{"pkgsPath"};
$pkgs = <FILE>;
close FILE;
} else {
$pkgs = $ENV{"pkgs"}
}

# Symlink to the packages that have been installed explicitly by the
# user.
for my $pkg (@{decode_json $pkgs}) {
for my $pkg (@{$nixAttrs->{pkgs}}) {
for my $path (@{$pkg->{paths}}) {
addPkg($path,
$ENV{"ignoreCollisions"} eq "1",
$ENV{"checkCollisionContents"} eq "1",
$nixAttrs->{ignoreCollisions},
$nixAttrs->{checkCollisionContents},
$pkg->{priority})
if -e $path;
}
Expand All @@ -251,7 +245,7 @@ sub addPkg {
my @pkgDirs = keys %postponed;
%postponed = ();
foreach my $pkgDir (sort @pkgDirs) {
addPkg($pkgDir, 2, $ENV{"checkCollisionContents"} eq "1", $priorityCounter++);
addPkg($pkgDir, 2, $nixAttrs->{checkCollisionContents}, $priorityCounter++);
}
}

Expand All @@ -277,7 +271,7 @@ sub addPkg {
print STDERR "created $nrLinks symlinks in user environment\n";


my $manifest = $ENV{"manifest"};
my $manifest = $nixAttrs->{manifest};
if ($manifest) {
symlink($manifest, "$out/manifest") or die "cannot create manifest";
}
9 changes: 4 additions & 5 deletions pkgs/build-support/buildenv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ let
in

runCommand name
rec {
{
inherit manifest ignoreCollisions checkCollisionContents passthru
meta pathsToLink extraPrefix postBuild
nativeBuildInputs buildInputs;
pkgs = builtins.toJSON (map (drv: {
pkgs = map (drv: {
paths =
# First add the usual output(s): respect if user has chosen explicitly,
# and otherwise use `meta.outputsToInstall`. The attribute is guaranteed
Expand All @@ -69,11 +69,10 @@ runCommand name
++ lib.filter (p: p!=null)
(builtins.map (outName: drv.${outName} or null) extraOutputsToInstall);
priority = drv.meta.priority or 5;
}) paths);
}) paths;
preferLocalBuild = true;
allowSubstitutes = false;
# XXX: The size is somewhat arbitrary
passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
__structuredAttrs = true;
}
''
${buildPackages.perl}/bin/perl -w ${builder}
Expand Down
2 changes: 2 additions & 0 deletions pkgs/build-support/fetchurl/write-mirror-list.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi

source $stdenv/setup

# !!! this is kinda hacky.
Expand Down
6 changes: 3 additions & 3 deletions pkgs/build-support/pkg-config-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ stdenv.mkDerivation {
dontConfigure = true;
dontUnpack = true;

# Additional flags passed to pkg-config.
addFlags = lib.optional stdenv.targetPlatform.isStatic "--static";

installPhase =
''
mkdir -p $out/bin $out/nix-support
Expand Down Expand Up @@ -116,6 +113,9 @@ stdenv.mkDerivation {
shell = getBin stdenvNoCC.shell + stdenvNoCC.shell.shellPath or "";
wrapperName = "PKG_CONFIG_WRAPPER";
inherit targetPrefix suffixSalt baseBinName;

# Additional flags passed to pkg-config.
addFlags = lib.optionalString stdenv.targetPlatform.isStatic "--static";
};

meta =
Expand Down
8 changes: 5 additions & 3 deletions pkgs/build-support/remove-references-to/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ stdenv.mkDerivation {
substituteAll ${./darwin-sign-fixup.sh} $out/nix-support/setup-hooks.sh
'';

inherit (builtins) storeDir;
shell = lib.getBin shell + (shell.shellPath or "");
signingUtils = if darwinCodeSign then signingUtils else null;
env = {
inherit (builtins) storeDir;
shell = lib.getBin shell + (shell.shellPath or "");
signingUtils = lib.optionalString darwinCodeSign signingUtils;
};
}
9 changes: 8 additions & 1 deletion pkgs/build-support/setup-hooks/autoreconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ preConfigurePhases="${preConfigurePhases:-} autoreconfPhase"

autoreconfPhase() {
runHook preAutoreconf
autoreconf ${autoreconfFlags:---install --force --verbose}

if [ -z "$__structuredAttrs" ]; then
autoreconfFlags=(${autoreconfFlags[*]})
fi

defaultFlags=(--install --force --verbose)
autoreconf "${autoreconfFlags[@]:-"${defaultFlags[@]}"}"

runHook postAutoreconf
}
8 changes: 5 additions & 3 deletions pkgs/build-support/substitute/substitute-all.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{ stdenvNoCC }:

args:
args@{ postInstall ? "", preInstall ? "", meta ? {}, ... }:

# see the substituteAll in the nixpkgs documentation for usage and constaints
stdenvNoCC.mkDerivation ({
stdenvNoCC.mkDerivation {
name = if args ? name then args.name else baseNameOf (toString args.src);
builder = ./substitute-all.sh;
inherit (args) src;
preferLocalBuild = true;
allowSubstitutes = false;
} // args)
env = removeAttrs args ["name" "src" "meta" "postInstall" "preInstall"];
inherit meta preInstall postInstall;
}
2 changes: 2 additions & 0 deletions pkgs/build-support/substitute/substitute-all.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi

source $stdenv/setup

eval "$preInstall"
Expand Down
14 changes: 6 additions & 8 deletions pkgs/build-support/trivial-builders/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, stdenvNoCC, lndir, runtimeShell, shellcheck, haskell }:
{ lib, stdenv, stdenvNoCC, lndir, runtimeShell, shellcheck, haskell, jq }:

let
inherit (lib)
Expand Down Expand Up @@ -542,12 +542,13 @@ rec {
args = removeAttrs args_ [ "name" "postBuild" ]
// {
inherit preferLocalBuild allowSubstitutes;
passAsFile = [ "paths" ];
__structuredAttrs = true;
}; # pass the defaults
in runCommand name args
''
mkdir -p $out
for i in $(cat $pathsPath); do
${jq}/bin/jq -r ".paths[]" < .attrs.json > paths
for i in $(cat paths); do
${lndir}/bin/lndir -silent $i $out
done
${postBuild}
Expand Down Expand Up @@ -646,11 +647,7 @@ rec {
}:
script:
runCommand name
(substitutions // {
# TODO(@Artturin:) substitutions should be inside the env attrset
# but users are likely passing non-substitution arguments through substitutions
# turn off __structuredAttrs to unbreak substituteAll
__structuredAttrs = false;
({
inherit meta;
inherit depsTargetTargetPropagated;
propagatedBuildInputs =
Expand All @@ -659,6 +656,7 @@ rec {
(lib.warnIf (deps != [ ]) "'deps' argument to makeSetupHook is deprecated and will be removed in release 23.11., Please use propagatedBuildInputs instead. content of deps: ${toString deps}"
propagatedBuildInputs ++ (if lib.isList deps then deps else [ deps ]));
strictDeps = true;
env = substitutions;
# TODO 2023-01, no backport: simplify to inherit passthru;
passthru = passthru
// optionalAttrs (substitutions?passthru)
Expand Down
62 changes: 34 additions & 28 deletions pkgs/by-name/cm/cmake/setup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ cmakeConfigurePhase() {
: ${cmakeDir:=.}
fi

if [ -z "$__structuredAttrs" ]; then
cmakeFlags=(${cmakeFlags[*]})
fi

if [ -z "${dontAddPrefix-}" ]; then
cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags"
cmakeFlags=("-DCMAKE_INSTALL_PREFIX=$prefix" "${cmakeFlags[@]}")
fi

# We should set the proper `CMAKE_SYSTEM_NAME`.
Expand All @@ -45,21 +49,21 @@ cmakeConfigurePhase() {
# Unfortunately cmake seems to expect absolute paths for ar, ranlib, and
# strip. Otherwise they are taken to be relative to the source root of the
# package being built.
cmakeFlags="-DCMAKE_CXX_COMPILER=$CXX $cmakeFlags"
cmakeFlags="-DCMAKE_C_COMPILER=$CC $cmakeFlags"
cmakeFlags="-DCMAKE_AR=$(command -v $AR) $cmakeFlags"
cmakeFlags="-DCMAKE_RANLIB=$(command -v $RANLIB) $cmakeFlags"
cmakeFlags="-DCMAKE_STRIP=$(command -v $STRIP) $cmakeFlags"
cmakeFlags=("-DCMAKE_CXX_COMPILER=$CXX" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_C_COMPILER=$CC" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_AR=$(command -v $AR)" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_RANLIB=$(command -v $RANLIB)" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_STRIP=$(command -v $STRIP)" "${cmakeFlags[@]}")

# on macOS we want to prefer Unix-style headers to Frameworks
# because we usually do not package the framework
cmakeFlags="-DCMAKE_FIND_FRAMEWORK=LAST $cmakeFlags"
cmakeFlags=("-DCMAKE_FIND_FRAMEWORK=LAST" "${cmakeFlags[@]}")

# we never want to use the global macOS SDK
cmakeFlags="-DCMAKE_OSX_SYSROOT= $cmakeFlags"
cmakeFlags=("-DCMAKE_OSX_SYSROOT=" "${cmakeFlags[@]}")

# correctly detect our clang compiler
cmakeFlags="-DCMAKE_POLICY_DEFAULT_CMP0025=NEW $cmakeFlags"
cmakeFlags=("-DCMAKE_POLICY_DEFAULT_CMP0025=NEW" "${cmakeFlags[@]}")

# This installs shared libraries with a fully-specified install
# name. By default, cmake installs shared libraries with just the
Expand All @@ -68,7 +72,7 @@ cmakeConfigurePhase() {
# libraries are in a system path or in the same directory as the
# executable. This flag makes the shared library accessible from its
# nix/store directory.
cmakeFlags="-DCMAKE_INSTALL_NAME_DIR=${!outputLib}/lib $cmakeFlags"
cmakeFlags=("-DCMAKE_INSTALL_NAME_DIR=${!outputLib}/lib" "${cmakeFlags[@]}")

# The docdir flag needs to include PROJECT_NAME as per GNU guidelines,
# try to extract it from CMakeLists.txt.
Expand All @@ -91,39 +95,41 @@ cmakeConfigurePhase() {
# This ensures correct paths with multiple output derivations
# It requires the project to use variables from GNUInstallDirs module
# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
cmakeFlags="-DCMAKE_INSTALL_BINDIR=${!outputBin}/bin $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_SBINDIR=${!outputBin}/sbin $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_INCLUDEDIR=${!outputInclude}/include $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_OLDINCLUDEDIR=${!outputInclude}/include $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_MANDIR=${!outputMan}/share/man $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_INFODIR=${!outputInfo}/share/info $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_DOCDIR=${!outputDoc}/share/doc/${shareDocName} $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_LIBDIR=${!outputLib}/lib $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_LIBEXECDIR=${!outputLib}/libexec $cmakeFlags"
cmakeFlags="-DCMAKE_INSTALL_LOCALEDIR=${!outputLib}/share/locale $cmakeFlags"
cmakeFlags=("-DCMAKE_INSTALL_BINDIR=${!outputBin}/bin" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_SBINDIR=${!outputBin}/sbin" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_INCLUDEDIR=${!outputInclude}/include" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_OLDINCLUDEDIR=${!outputInclude}/include" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_MANDIR=${!outputMan}/share/man" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_INFODIR=${!outputInfo}/share/info" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_DOCDIR=${!outputDoc}/share/doc/${shareDocName}" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_LIBDIR=${!outputLib}/lib" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_LIBEXECDIR=${!outputLib}/libexec" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_INSTALL_LOCALEDIR=${!outputLib}/share/locale" "${cmakeFlags[@]}")

# Don’t build tests when doCheck = false
if [ -z "${doCheck-}" ]; then
cmakeFlags="-DBUILD_TESTING=OFF $cmakeFlags"
cmakeFlags=("-DBUILD_TESTING=OFF" "${cmakeFlags[@]}")
fi

# Always build Release, to ensure optimisation flags
cmakeFlags="-DCMAKE_BUILD_TYPE=${cmakeBuildType:-Release} $cmakeFlags"
cmakeFlags=("-DCMAKE_BUILD_TYPE=${cmakeBuildType:-Release}" "${cmakeFlags[@]}")

# Disable user package registry to avoid potential side effects
# and unecessary attempts to access non-existent home folder
# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#disabling-the-package-registry
cmakeFlags="-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON $cmakeFlags"
cmakeFlags="-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF $cmakeFlags"
cmakeFlags="-DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF $cmakeFlags"
cmakeFlags=("-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF" "${cmakeFlags[@]}")
cmakeFlags=("-DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF" "${cmakeFlags[@]}")

if [ "${buildPhase-}" = ninjaBuildPhase ]; then
cmakeFlags="-GNinja $cmakeFlags"
cmakeFlags=("-GNinja" "${cmakeFlags[@]}")
fi

echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
cmakeFlags=("${cmakeFlags[@]}" "${cmakeFlagsArray[@]}")

echo "cmake flags: ${cmakeFlags[@]}"

cmake "$cmakeDir" $cmakeFlags "${cmakeFlagsArray[@]}"
cmake "$cmakeDir" "${cmakeFlags[@]}"

if ! [[ -v enableParallelBuilding ]]; then
enableParallelBuilding=1
Expand Down
8 changes: 4 additions & 4 deletions pkgs/development/compilers/gcc/common/extra-target-flags.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ in
] ++ lib.optionals (! withoutTargetLibc) [
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
]);
in mkFlags libcCross langD
++ lib.optionals (!withoutTargetLibc) (mkFlags (threadsCross.package or null) langD)
in toString (mkFlags libcCross langD
++ lib.optionals (!withoutTargetLibc) (mkFlags (threadsCross.package or null) langD))
;

EXTRA_LDFLAGS_FOR_TARGET = let
Expand All @@ -27,7 +27,7 @@ in
"-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}"
"-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}"
]));
in mkFlags libcCross
++ lib.optionals (!withoutTargetLibc) (mkFlags (threadsCross.package or null))
in toString (mkFlags libcCross
++ lib.optionals (!withoutTargetLibc) (mkFlags (threadsCross.package or null)))
;
}
Loading