aboutsummaryrefslogtreecommitdiff
path: root/pkgs/build-support
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support')
-rwxr-xr-xpkgs/build-support/appimage/appimage-exec.sh10
-rw-r--r--pkgs/build-support/bintools-wrapper/default.nix4
-rw-r--r--pkgs/build-support/build-bazel-package/default.nix2
-rw-r--r--pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix43
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix2
-rw-r--r--pkgs/build-support/docker/default.nix44
-rw-r--r--pkgs/build-support/docker/detjson.py2
-rw-r--r--pkgs/build-support/docker/examples.nix14
-rw-r--r--pkgs/build-support/fetchsvnrevision/default.nix2
-rw-r--r--pkgs/build-support/install-shell-files/default.nix12
-rw-r--r--pkgs/build-support/libredirect/libredirect.c7
-rw-r--r--pkgs/build-support/make-desktopitem/default.nix70
-rw-r--r--pkgs/build-support/rust/build-rust-crate/configure-crate.nix11
-rw-r--r--pkgs/build-support/rust/build-rust-crate/default.nix22
-rw-r--r--pkgs/build-support/rust/build-rust-crate/test/default.nix53
-rw-r--r--pkgs/build-support/rust/default-crate-overrides.nix30
-rw-r--r--pkgs/build-support/setup-hooks/install-shell-files.sh125
-rwxr-xr-xpkgs/build-support/setup-hooks/move-systemd-user-units.sh25
-rw-r--r--pkgs/build-support/setup-hooks/validate-pkg-config.sh3
-rw-r--r--pkgs/build-support/singularity-tools/default.nix4
-rw-r--r--pkgs/build-support/vm/default.nix32
-rw-r--r--pkgs/build-support/wrapper-common/utils.bash10
-rw-r--r--pkgs/build-support/writers/default.nix7
23 files changed, 356 insertions, 178 deletions
diff --git a/pkgs/build-support/appimage/appimage-exec.sh b/pkgs/build-support/appimage/appimage-exec.sh
index 82ebdd0bbe4a..7986c589667b 100755
--- a/pkgs/build-support/appimage/appimage-exec.sh
+++ b/pkgs/build-support/appimage/appimage-exec.sh
@@ -1,4 +1,6 @@
#!@shell@
+# shellcheck shell=bash
+
if [ -n "$DEBUG" ] ; then
set -x
fi
@@ -13,8 +15,10 @@ unpack() {
local out="$2"
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
- local appimageSignature=$(readelf -h "$src" | awk 'NR==2{print $10$11;}')
- local appimageType=$(readelf -h "$src" | awk 'NR==2{print $12;}')
+ local appimageSignature;
+ appimageSignature="$(LC_ALL=C readelf -h "$src" | awk 'NR==2{print $10$11;}')"
+ local appimageType;
+ appimageType="$(LC_ALL=C readelf -h "$src" | awk 'NR==2{print $12;}')"
# check AppImage signature
if [ "$appimageSignature" != "4149" ]; then
@@ -35,7 +39,7 @@ unpack() {
# multiarch offset one-liner using same method as AppImage
# see https://gist.github.com/probonopd/a490ba3401b5ef7b881d5e603fa20c93
- offset=$(readelf -h "$src" | awk 'NR==13{e_shoff=$5} NR==18{e_shentsize=$5} NR==19{e_shnum=$5} END{print e_shoff+e_shentsize*e_shnum}')
+ offset=$(LC_ALL=C readelf -h "$src" | awk 'NR==13{e_shoff=$5} NR==18{e_shentsize=$5} NR==19{e_shnum=$5} END{print e_shoff+e_shentsize*e_shnum}')
echo "Uncompress $(basename "$src") of type $appimageType @ offset $offset"
unsquashfs -q -d "$out" -o "$offset" "$src"
chmod go-w "$out"
diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix
index 786f0f9c5983..3b1b8ff570a8 100644
--- a/pkgs/build-support/bintools-wrapper/default.nix
+++ b/pkgs/build-support/bintools-wrapper/default.nix
@@ -179,12 +179,14 @@ stdenv.mkDerivation {
mips64 = "btsmip";
mips64el = "ltsmip";
}.${targetPlatform.parsed.cpu.name}
+ else if targetPlatform.isMmix then "mmix"
else if targetPlatform.isPower then if targetPlatform.isBigEndian then "ppc" else "lppc"
else if targetPlatform.isSparc then "sparc"
else if targetPlatform.isMsp430 then "msp430"
else if targetPlatform.isAvr then "avr"
else if targetPlatform.isAlpha then "alpha"
else if targetPlatform.isVc4 then "vc4"
+ else if targetPlatform.isOr1k then "or1k"
else throw "unknown emulation for platform: ${targetPlatform.config}";
in if targetPlatform.useLLVM or false then ""
else targetPlatform.platform.bfdEmulation or (fmt + sep + arch);
@@ -252,7 +254,7 @@ stdenv.mkDerivation {
# Ensure consistent LC_VERSION_MIN_MACOSX and remove LC_UUID.
+ optionalString stdenv.targetPlatform.isMacOS ''
- echo "-macosx_version_min 10.12 -sdk_version 10.12 -no_uuid" >> $out/nix-support/libc-ldflags-before
+ echo "-sdk_version 10.12 -no_uuid" >> $out/nix-support/libc-ldflags-before
''
##
diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix
index 4d22a329e416..10a331bcc9e7 100644
--- a/pkgs/build-support/build-bazel-package/default.nix
+++ b/pkgs/build-support/build-bazel-package/default.nix
@@ -9,7 +9,7 @@ let
in
args@{
- name
+ name ? "${args.pname}-${args.version}"
, bazel ? bazelPkg
, bazelFlags ? []
, bazelBuildFlags ? []
diff --git a/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix b/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix
index c7cfd27d3faa..3a3c9e932fdb 100644
--- a/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix
+++ b/pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix
@@ -50,7 +50,7 @@ let
"ssl/certs"
"pki"
];
- in concatStringsSep " \\\n "
+ in concatStringsSep "\n "
(map (file: "--ro-bind-try /etc/${file} /etc/${file}") files);
init = run: writeShellScriptBin "${name}-init" ''
@@ -59,46 +59,49 @@ let
'';
bwrapCmd = { initArgs ? "" }: ''
- blacklist="/nix /dev /proc /etc"
- ro_mounts=""
+ blacklist=(/nix /dev /proc /etc)
+ ro_mounts=()
for i in ${env}/*; do
path="/''${i##*/}"
if [[ $path == '/etc' ]]; then
continue
fi
- ro_mounts="$ro_mounts --ro-bind $i $path"
- blacklist="$blacklist $path"
+ ro_mounts+=(--ro-bind "$i" "$path")
+ blacklist+=("$path")
done
if [[ -d ${env}/etc ]]; then
for i in ${env}/etc/*; do
path="/''${i##*/}"
- ro_mounts="$ro_mounts --ro-bind $i /etc$path"
+ ro_mounts+=(--ro-bind "$i" "/etc$path")
done
fi
- auto_mounts=""
+ declare -a auto_mounts
# loop through all directories in the root
for dir in /*; do
# if it is a directory and it is not in the blacklist
- if [[ -d "$dir" ]] && grep -v "$dir" <<< "$blacklist" >/dev/null; then
+ if [[ -d "$dir" ]] && [[ ! "''${blacklist[@]}" =~ "$dir" ]]; then
# add it to the mount list
- auto_mounts="$auto_mounts --bind $dir $dir"
+ auto_mounts+=(--bind "$dir" "$dir")
fi
done
- exec ${bubblewrap}/bin/bwrap \
- --dev-bind /dev /dev \
- --proc /proc \
- --chdir "$(pwd)" \
- --unshare-all \
- --share-net \
- --die-with-parent \
- --ro-bind /nix /nix \
- ${etcBindFlags} \
- $ro_mounts \
- $auto_mounts \
+ cmd=(
+ ${bubblewrap}/bin/bwrap
+ --dev-bind /dev /dev
+ --proc /proc
+ --chdir "$(pwd)"
+ --unshare-all
+ --share-net
+ --die-with-parent
+ --ro-bind /nix /nix
+ ${etcBindFlags}
+ "''${ro_mounts[@]}"
+ "''${auto_mounts[@]}"
${init runScript}/bin/${name}-init ${initArgs}
+ )
+ exec "''${cmd[@]}"
'';
bin = writeShellScriptBin name (bwrapCmd { initArgs = ''"$@"''; });
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index 0e4e76d72843..09cef8b8678d 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -57,7 +57,7 @@ let
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
expand-response-params =
- if buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null"
+ if (buildPackages.stdenv.hasCC or false) && buildPackages.stdenv.cc != "/dev/null"
then import ../expand-response-params { inherit (buildPackages) stdenv; }
else "";
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index b2c132afd741..db1062e1b5d8 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -15,7 +15,6 @@
moreutils,
nix,
pigz,
- referencesByPopularity,
rsync,
runCommand,
runtimeShell,
@@ -25,12 +24,13 @@
storeDir ? builtins.storeDir,
substituteAll,
symlinkJoin,
- utillinux,
+ util-linux,
vmTools,
writeReferencesToFile,
writeScript,
writeText,
writePython3,
+ system, # Note: This is the cross system we're compiling for
}:
# WARNING: this API is unstable and may be subject to backwards-incompatible changes in the future.
@@ -48,7 +48,7 @@ let
# A user is required by nix
# https://github.com/NixOS/nix/blob/9348f9291e5d9e4ba3c4347ea1b235640f54fd79/src/libutil/util.cc#L478
export USER=nobody
- ${nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contentsList;}}/registration
+ ${buildPackages.nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contentsList;}}/registration
mkdir -p nix/var/nix/gcroots/docker/
for i in ${lib.concatStringsSep " " contentsList}; do
@@ -56,6 +56,16 @@ let
done;
'';
+ # Map nixpkgs architecture to Docker notation
+ # Reference: https://github.com/docker-library/official-images#architectures-other-than-amd64
+ getArch = nixSystem: {
+ aarch64-linux = "arm64v8";
+ armv7l-linux = "arm32v7";
+ x86_64-linux = "amd64";
+ powerpc64le-linux = "ppc64le";
+ i686-linux = "i386";
+ }.${nixSystem} or "Can't map Nix system ${nixSystem} to Docker architecture notation. Please check that your input and your requested build are correct or update the mapping in Nixpkgs.";
+
in
rec {
@@ -72,7 +82,7 @@ rec {
, imageDigest
, sha256
, os ? "linux"
- , arch ? buildPackages.go.GOARCH
+ , arch ? getArch system
# This is used to set name to the pulled image
, finalImageName ? imageName
@@ -194,7 +204,7 @@ rec {
};
inherit fromImage fromImageName fromImageTag;
- nativeBuildInputs = [ utillinux e2fsprogs jshon rsync jq ];
+ nativeBuildInputs = [ util-linux e2fsprogs jshon rsync jq ];
} ''
mkdir disk
mkfs /dev/${vmTools.hd}
@@ -340,7 +350,7 @@ rec {
# Tar up the layer and throw it into 'layer.tar'.
echo "Packing layer..."
mkdir $out
- tarhash=$(tar -C layer --hard-dereference --sort=name --mtime="@$SOURCE_DATE_EPOCH" --owner=${toString uid} --group=${toString gid} -cf - . | tee $out/layer.tar | tarsum)
+ tarhash=$(tar -C layer --hard-dereference --sort=name --mtime="@$SOURCE_DATE_EPOCH" --owner=${toString uid} --group=${toString gid} -cf - . | tee -p $out/layer.tar | tarsum)
# Add a 'checksum' field to the JSON, with the value set to the
# checksum of the tarball.
@@ -425,7 +435,7 @@ rec {
echo "Packing layer..."
mkdir -p $out
tarhash=$(tar -C layer --hard-dereference --sort=name --mtime="@$SOURCE_DATE_EPOCH" -cf - . |
- tee $out/layer.tar |
+ tee -p $out/layer.tar |
${tarsum}/bin/tarsum)
cat ${baseJson} | jshon -s "$tarhash" -i checksum > $out/json
@@ -443,7 +453,7 @@ rec {
runCommand "${name}.tar.gz" {
inherit (stream) imageName;
passthru = { inherit (stream) imageTag; };
- buildInputs = [ pigz ];
+ nativeBuildInputs = [ pigz ];
} "${stream} | pigz -nT > $out";
# 1. extract the base image
@@ -488,7 +498,7 @@ rec {
baseJson = let
pure = writeText "${baseName}-config.json" (builtins.toJSON {
inherit created config;
- architecture = buildPackages.go.GOARCH;
+ architecture = getArch system;
os = "linux";
});
impure = runCommand "${baseName}-config.json"
@@ -715,7 +725,7 @@ rec {
streamScript = writePython3 "stream" {} ./stream_layered_image.py;
baseJson = writeText "${name}-base.json" (builtins.toJSON {
inherit config;
- architecture = buildPackages.go.GOARCH;
+ architecture = getArch system;
os = "linux";
});
@@ -761,8 +771,8 @@ rec {
then tag
else
lib.head (lib.strings.splitString "-" (baseNameOf conf.outPath));
- paths = referencesByPopularity overallClosure;
- buildInputs = [ jq ];
+ paths = buildPackages.referencesByPopularity overallClosure;
+ nativeBuildInputs = [ jq ];
} ''
${if (tag == null) then ''
outName="$(basename "$out")"
@@ -819,8 +829,14 @@ rec {
'';
result = runCommand "stream-${name}" {
inherit (conf) imageName;
- passthru = { inherit (conf) imageTag; };
- buildInputs = [ makeWrapper ];
+ passthru = {
+ inherit (conf) imageTag;
+
+ # Distinguish tarballs and exes at the Nix level so functions that
+ # take images can know in advance how the image is supposed to be used.
+ isExe = true;
+ };
+ nativeBuildInputs = [ makeWrapper ];
} ''
makeWrapper ${streamScript} $out --add-flags ${conf}
'';
diff --git a/pkgs/build-support/docker/detjson.py b/pkgs/build-support/docker/detjson.py
index 439c21313878..fe82cbea11bb 100644
--- a/pkgs/build-support/docker/detjson.py
+++ b/pkgs/build-support/docker/detjson.py
@@ -37,4 +37,4 @@ def main():
json.dump(j, sys.stdout, sort_keys=True)
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index 4a611add8a12..3f30f1a2adb4 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -7,7 +7,7 @@
# $ nix-build '<nixpkgs>' -A dockerTools.examples.redis
# $ docker load < result
-{ pkgs, buildImage, pullImage, shadowSetup, buildImageWithNixDb }:
+{ pkgs, buildImage, pullImage, shadowSetup, buildImageWithNixDb, pkgsCross }:
rec {
# 1. basic example
@@ -407,4 +407,16 @@ rec {
contents = [ pkgs.bash pkgs.coreutils ] ++ nonRootShadowSetup { uid = 999; user = "somebody"; };
};
+ # basic example, with cross compilation
+ cross = let
+ # Cross compile for x86_64 if on aarch64
+ crossPkgs =
+ if pkgs.system == "aarch64-linux" then pkgsCross.gnu64
+ else pkgsCross.aarch64-multiplatform;
+ in crossPkgs.dockerTools.buildImage {
+ name = "hello-cross";
+ tag = "latest";
+ contents = crossPkgs.hello;
+ };
+
}
diff --git a/pkgs/build-support/fetchsvnrevision/default.nix b/pkgs/build-support/fetchsvnrevision/default.nix
index 288451a225c7..f2e2a11da8d5 100644
--- a/pkgs/build-support/fetchsvnrevision/default.nix
+++ b/pkgs/build-support/fetchsvnrevision/default.nix
@@ -7,4 +7,4 @@ runCommand: subversion: repository:
rev=$(echo p | svn ls -v --depth empty ${repository} |awk '{ print $1 }')
echo "[ \"$rev\" ]" > $out
echo Latest revision is $rev
- '') \ No newline at end of file
+ '')
diff --git a/pkgs/build-support/install-shell-files/default.nix b/pkgs/build-support/install-shell-files/default.nix
index e1f2e24dd875..d50661ddc65d 100644
--- a/pkgs/build-support/install-shell-files/default.nix
+++ b/pkgs/build-support/install-shell-files/default.nix
@@ -1,4 +1,12 @@
-{ makeSetupHook }:
+{ makeSetupHook, tests }:
# See the header comment in ../setup-hooks/install-shell-files.sh for example usage.
-makeSetupHook { name = "install-shell-files"; } ../setup-hooks/install-shell-files.sh
+let
+ setupHook = makeSetupHook { name = "install-shell-files"; } ../setup-hooks/install-shell-files.sh;
+in
+
+setupHook.overrideAttrs (oldAttrs: {
+ passthru = (oldAttrs.passthru or {}) // {
+ tests = tests.install-shell-files;
+ };
+})
diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c
index e7f74c736ab0..c8d6956a6bfe 100644
--- a/pkgs/build-support/libredirect/libredirect.c
+++ b/pkgs/build-support/libredirect/libredirect.c
@@ -121,6 +121,13 @@ FILE * fopen(const char * path, const char * mode)
return fopen_real(rewrite(path, buf), mode);
}
+FILE * __nss_files_fopen(const char * path)
+{
+ FILE * (*__nss_files_fopen_real) (const char *) = dlsym(RTLD_NEXT, "__nss_files_fopen");
+ char buf[PATH_MAX];
+ return __nss_files_fopen_real(rewrite(path, buf));
+}
+
FILE * fopen64(const char * path, const char * mode)
{
FILE * (*fopen64_real) (const char *, const char *) = dlsym(RTLD_NEXT, "fopen64");
diff --git a/pkgs/build-support/make-desktopitem/default.nix b/pkgs/build-support/make-desktopitem/default.nix
index 8355a5ad29bc..8e51dc1b8480 100644
--- a/pkgs/build-support/make-desktopitem/default.nix
+++ b/pkgs/build-support/make-desktopitem/default.nix
@@ -1,50 +1,60 @@
{ lib, runCommandLocal, desktop-file-utils }:
-{ name
+# See https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
+{ name # The name of the desktop file
, type ? "Application"
, exec
, icon ? null
, comment ? null
-, terminal ? "false"
-, desktopName
+, terminal ? false
+, desktopName # The name of the application
, genericName ? null
, mimeType ? null
, categories ? null
, startupNotify ? null
-, extraEntries ? null
+, extraDesktopEntries ? {} # Extra key-value pairs to add to the [Desktop Entry] section. This may override other values
+, extraEntries ? "" # Extra configuration. Will be appended to the end of the file and may thus contain extra sections
, fileValidation ? true # whether to validate resulting desktop file.
}:
let
- optionalEntriesList = [{k="Icon"; v=icon;}
- {k="Comment"; v=comment;}
- {k="GenericName"; v=genericName;}
- {k="MimeType"; v=mimeType;}
- {k="Categories"; v=categories;}
- {k="StartupNotify"; v=startupNotify;}];
+ # like builtins.toString, but null -> null instead of null -> ""
+ nullableToString = value: if value == null then null
+ else if builtins.isBool value then lib.boolToString value
+ else builtins.toString value;
- valueNotNull = {k, v}: v != null;
- entriesToKeep = builtins.filter valueNotNull optionalEntriesList;
+ # The [Desktop entry] section of the desktop file, as attribute set.
+ mainSection = {
+ "Type" = toString type;
+ "Exec" = nullableToString exec;
+ "Icon" = nullableToString icon;
+ "Comment" = nullableToString comment;
+ "Terminal" = nullableToString terminal;
+ "Name" = toString desktopName;
+ "GenericName" = nullableToString genericName;
+ "MimeType" = nullableToString mimeType;
+ "Categories" = nullableToString categories;
+ "StartupNotify" = nullableToString startupNotify;
+ } // extraDesktopEntries;
- mkEntry = {k, v}: k + "=" + v;
- optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
+ # Map all entries to a list of lines
+ desktopFileStrings =
+ ["[Desktop Entry]"]
+ ++ builtins.filter
+ (v: v != null)
+ (lib.mapAttrsToList
+ (name: value: if value != null then "${name}=${value}" else null)
+ mainSection
+ )
+ ++ (if extraEntries == "" then [] else ["${extraEntries}"]);
in
runCommandLocal "${name}.desktop" {}
- ''
+ (''
mkdir -p "$out/share/applications"
cat > "$out/share/applications/${name}.desktop" <<EOF
- [Desktop Entry]
- Type=${type}
- Exec=${exec}
- Terminal=${terminal}
- Name=${desktopName}
- ${optionalEntriesString}
- ${if extraEntries == null then ''EOF'' else ''
- ${extraEntries}
- EOF''}
-
- ${lib.optionalString fileValidation ''
- echo "Running desktop-file validation"
- ${desktop-file-utils}/bin/desktop-file-validate "$out/share/applications/${name}.desktop"
- ''}
- ''
+ ${builtins.concatStringsSep "\n" desktopFileStrings}
+ EOF
+ '' + lib.optionalString fileValidation ''
+ echo "Running desktop-file validation"
+ ${desktop-file-utils}/bin/desktop-file-validate "$out/share/applications/${name}.desktop"
+ '')
diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
index a95b356646e1..18587f7047c4 100644
--- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
+++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }:
+{ lib, stdenv, rust, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }:
{
build
, buildDependencies
@@ -17,7 +17,6 @@
, libName
, libPath
, release
-, target_os
, verbose
, workspace_member }:
let version_ = lib.splitString "-" crateVersion;
@@ -124,8 +123,8 @@ in ''
export CARGO_PKG_AUTHORS="${authors}"
export CARGO_PKG_DESCRIPTION="${crateDescription}"
- export CARGO_CFG_TARGET_ARCH=${stdenv.hostPlatform.parsed.cpu.name}
- export CARGO_CFG_TARGET_OS=${target_os}
+ export CARGO_CFG_TARGET_ARCH=${rust.toTargetArch stdenv.hostPlatform}
+ export CARGO_CFG_TARGET_OS=${rust.toTargetOs stdenv.hostPlatform}
export CARGO_CFG_TARGET_FAMILY="unix"
export CARGO_CFG_UNIX=1
export CARGO_CFG_TARGET_ENV="gnu"
@@ -136,8 +135,8 @@ in ''
export CARGO_MANIFEST_DIR=$(pwd)
export DEBUG="${toString (!release)}"
export OPT_LEVEL="${toString optLevel}"
- export TARGET="${stdenv.hostPlatform.config}"
- export HOST="${stdenv.hostPlatform.config}"
+ export TARGET="${rust.toRustTarget stdenv.hostPlatform}"
+ export HOST="${rust.toRustTarget stdenv.buildPlatform}"
export PROFILE=${if release then "release" else "debug"}
export OUT_DIR=$(pwd)/target/build/${crateName}.out
export CARGO_PKG_VERSION_MAJOR=${lib.elemAt version 0}
diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix
index d559aba16165..9d98e0851780 100644
--- a/pkgs/build-support/rust/build-rust-crate/default.nix
+++ b/pkgs/build-support/rust/build-rust-crate/default.nix
@@ -4,15 +4,10 @@
# This can be useful for deploying packages with NixOps, and to share
# binary dependencies between projects.
-{ lib, stdenv, defaultCrateOverrides, fetchCrate, rustc, rust, cargo, jq }:
+{ lib, stdenv, defaultCrateOverrides, fetchCrate, pkgsBuildBuild, rustc, rust
+, cargo, jq }:
let
- # This doesn't appear to be officially documented anywhere yet.
- # See https://github.com/rust-lang-nursery/rust-forge/issues/101.
- target_os = if stdenv.hostPlatform.isDarwin
- then "macos"
- else stdenv.hostPlatform.parsed.kernel.name;
-
# Create rustc arguments to link against the given list of dependencies
# and renames.
#
@@ -51,7 +46,7 @@ let
inherit (import ./log.nix { inherit lib; }) noisily echo_colored;
configureCrate = import ./configure-crate.nix {
- inherit lib stdenv echo_colored noisily mkRustcDepArgs mkRustcFeatureArgs;
+ inherit lib stdenv rust echo_colored noisily mkRustcDepArgs mkRustcFeatureArgs;
};
buildCrate = import ./build-crate.nix {
@@ -83,6 +78,8 @@ in
# A list of rust/cargo features to enable while building the crate.
# Example: [ "std" "async" ]
, features
+ # Additional native build inputs for building this crate.
+ , nativeBuildInputs
# Additional build inputs for building this crate.
#
# Example: [ pkgs.openssl ]
@@ -188,12 +185,13 @@ let crate = crate_ // (lib.attrByPath [ crate_.crateName ] (attr: {}) crateOverr
dependencies_ = dependencies;
buildDependencies_ = buildDependencies;
processedAttrs = [
- "src" "buildInputs" "crateBin" "crateLib" "libName" "libPath"
+ "src" "nativeBuildInputs" "buildInputs" "crateBin" "crateLib" "libName" "libPath"
"buildDependencies" "dependencies" "features" "crateRenames"
"crateName" "version" "build" "authors" "colors" "edition"
"buildTests"
];
extraDerivationAttrs = builtins.removeAttrs crate processedAttrs;
+ nativeBuildInputs_ = nativeBuildInputs;
buildInputs_ = buildInputs;
extraRustcOpts_ = extraRustcOpts;
buildTests_ = buildTests;
@@ -225,7 +223,8 @@ stdenv.mkDerivation (rec {
src = crate.src or (fetchCrate { inherit (crate) crateName version sha256; });
name = "rust_${crate.crateName}-${crate.version}${lib.optionalString buildTests_ "-test"}";
version = crate.version;
- depsBuildBuild = [ rust stdenv.cc cargo jq ];
+ depsBuildBuild = [ pkgsBuildBuild.stdenv.cc ];
+ nativeBuildInputs = [ rust stdenv.cc cargo jq ] ++ (crate.nativeBuildInputs or []) ++ nativeBuildInputs_;
buildInputs = (crate.buildInputs or []) ++ buildInputs_;
dependencies = map lib.getLib dependencies_;
buildDependencies = map lib.getLib buildDependencies_;
@@ -279,7 +278,7 @@ stdenv.mkDerivation (rec {
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription
crateFeatures crateRenames libName build workspace_member release libPath crateVersion
extraLinkFlags extraRustcOpts
- crateAuthors crateHomepage verbose colors target_os;
+ crateAuthors crateHomepage verbose colors;
};
buildPhase = buildCrate {
inherit crateName dependencies
@@ -301,6 +300,7 @@ stdenv.mkDerivation (rec {
verbose = crate_.verbose or true;
extraRustcOpts = [];
features = [];
+ nativeBuildInputs = [];
buildInputs = [];
crateOverrides = defaultCrateOverrides;
preUnpack = crate_.preUnpack or "";
diff --git a/pkgs/build-support/rust/build-rust-crate/test/default.nix b/pkgs/build-support/rust/build-rust-crate/test/default.nix
index 24ddc11459ec..f6cd54c4ee3e 100644
--- a/pkgs/build-support/rust/build-rust-crate/test/default.nix
+++ b/pkgs/build-support/rust/build-rust-crate/test/default.nix
@@ -1,4 +1,5 @@
{ lib
+, buildPackages
, buildRustCrate
, callPackage
, releaseTools
@@ -10,13 +11,14 @@
}:
let
- mkCrate = args: let
+ mkCrate = buildRustCrate: args: let
p = {
crateName = "nixtestcrate";
version = "0.1.0";
authors = [ "Test <test@example.com>" ];
} // args;
in buildRustCrate p;
+ mkHostCrate = mkCrate buildRustCrate;
mkCargoToml =
{ name, crateVersion ? "0.1.0", path ? "Cargo.toml" }:
@@ -68,15 +70,15 @@ let
mkLib = name: mkFile name "pub fn test() -> i32 { return 23; }";
mkTest = crateArgs: let
- crate = mkCrate (builtins.removeAttrs crateArgs ["expectedTestOutput"]);
+ crate = mkHostCrate (builtins.removeAttrs crateArgs ["expectedTestOutput"]);
hasTests = crateArgs.buildTests or false;
expectedTestOutputs = crateArgs.expectedTestOutputs or null;
- binaries = map (v: ''"${v.name}"'') (crateArgs.crateBin or []);
+ binaries = map (v: lib.escapeShellArg v.name) (crateArgs.crateBin or []);
isLib = crateArgs ? libName || crateArgs ? libPath;
crateName = crateArgs.crateName or "nixtestcrate";
libName = crateArgs.libName or crateName;
- libTestBinary = if !isLib then null else mkCrate {
+ libTestBinary = if !isLib then null else mkHostCrate {
crateName = "run-test-${crateName}";
dependencies = [ crate ];
src = mkBinExtern "src/main.rs" libName;
@@ -89,18 +91,27 @@ let
runCommand "run-buildRustCrate-${crateName}-test" {
nativeBuildInputs = [ crate ];
} (if !hasTests then ''
- ${lib.concatStringsSep "\n" binaries}
+ ${lib.concatMapStringsSep "\n" (binary:
+ # Can't actually run the binary when cross-compiling
+ (lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "type ") + binary
+ ) binaries}
${lib.optionalString isLib ''
test -e ${crate}/lib/*.rlib || exit 1
- ${libTestBinary}/bin/run-test-${crateName}
+ ${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "test -x "} \
+ ${libTestBinary}/bin/run-test-${crateName}
''}
touch $out
- '' else ''
+ '' else if stdenv.hostPlatform == stdenv.buildPlatform then ''
for file in ${crate}/tests/*; do
$file 2>&1 >> $out
done
set -e
${lib.concatMapStringsSep "\n" (o: "grep '${o}' $out || { echo 'output \"${o}\" not found in:'; cat $out; exit 23; }") expectedTestOutputs}
+ '' else ''
+ for file in ${crate}/tests/*; do
+ test -x "$file"
+ done
+ touch "$out"
''
);
@@ -109,7 +120,7 @@ let
`name` is used as part of the derivation name that performs the checking.
- `crateArgs` is passed to `mkCrate` to build the crate with `buildRustCrate`.
+ `crateArgs` is passed to `mkHostCrate` to build the crate with `buildRustCrate`.
`expectedFiles` contains a list of expected file paths in the output. E.g.
`[ "./bin/my_binary" ]`.
@@ -124,7 +135,7 @@ let
assert (builtins.isList expectedFiles);
let
- crate = mkCrate (builtins.removeAttrs crateArgs ["expectedTestOutput"]);
+ crate = mkHostCrate (builtins.removeAttrs crateArgs ["expectedTestOutput"]);
crateOutput = if output == null then crate else crate."${output}";
expectedFilesFile = writeTextFile {
name = "expected-files-${name}";
@@ -188,17 +199,17 @@ let
crateBinRename1 = {
crateBin = [{ name = "my-binary-rename1"; }];
src = mkBinExtern "src/main.rs" "foo_renamed";
- dependencies = [ (mkCrate { crateName = "foo"; src = mkLib "src/lib.rs"; }) ];
+ dependencies = [ (mkHostCrate { crateName = "foo"; src = mkLib "src/lib.rs"; }) ];
crateRenames = { "foo" = "foo_renamed"; };
};
crateBinRename2 = {
crateBin = [{ name = "my-binary-rename2"; }];
src = mkBinExtern "src/main.rs" "foo_renamed";
- dependencies = [ (mkCrate { crateName = "foo"; libName = "foolib"; src = mkLib "src/lib.rs"; }) ];
+ dependencies = [ (mkHostCrate { crateName = "foo"; libName = "foolib"; src = mkLib "src/lib.rs"; }) ];
crateRenames = { "foo" = "foo_renamed"; };
};
crateBinRenameMultiVersion = let
- crateWithVersion = version: mkCrate {
+ crateWithVersion = version: mkHostCrate {
crateName = "my_lib";
inherit version;
src = mkFile "src/lib.rs" ''
@@ -307,7 +318,7 @@ let
fn main() {}
'';
dependencies = [
- (mkCrate {
+ (mkHostCrate {
crateName = "somerlib";
type = [ "rlib" ];
src = mkLib "src/lib.rs";
@@ -315,7 +326,7 @@ let
];
};
buildScriptDeps = let
- depCrate = boolVal: mkCrate {
+ depCrate = buildRustCrate: boolVal: mkCrate buildRustCrate {
crateName = "bar";
src = mkFile "src/lib.rs" ''
pub const baz: bool = ${boolVal};
@@ -339,8 +350,8 @@ let
'')
];
};
- buildDependencies = [ (depCrate "true") ];
- dependencies = [ (depCrate "false") ];
+ buildDependencies = [ (depCrate buildPackages.buildRustCrate "true") ];
+ dependencies = [ (depCrate buildRustCrate "false") ];
buildTests = true;
expectedTestOutputs = [ "test baz_false ... ok" ];
};
@@ -373,7 +384,7 @@ let
# Regression test for https://github.com/NixOS/nixpkgs/pull/88054
# Build script output should be rewritten as valid env vars.
buildScriptIncludeDirDeps = let
- depCrate = mkCrate {
+ depCrate = mkHostCrate {
crateName = "bar";
src = symlinkJoin {
name = "build-script-and-include-dir-bar";
@@ -460,7 +471,7 @@ let
mkdir -p $out/lib
# Note: On darwin (which defaults to clang) we have to add
# `-undefined dynamic_lookup` as otherwise the compilation fails.
- cc -shared \
+ $CC -shared \
${lib.optionalString stdenv.isDarwin "-undefined dynamic_lookup"} \
-o $out/lib/${name}${stdenv.hostPlatform.extensions.sharedLibrary} ${src}
'';
@@ -609,9 +620,11 @@ let
pkg = brotliCrates.brotli_2_5_0 {};
in runCommand "run-brotli-test-cmd" {
nativeBuildInputs = [ pkg ];
- } ''
+ } (if stdenv.hostPlatform == stdenv.buildPlatform then ''
${pkg}/bin/brotli -c ${pkg}/bin/brotli > /dev/null && touch $out
- '';
+ '' else ''
+ test -x '${pkg}/bin/brotli' && touch $out
+ '');
allocNoStdLibTest = let
pkg = brotliCrates.alloc_no_stdlib_1_3_0 {};
in runCommand "run-alloc-no-stdlib-test-cmd" {
diff --git a/pkgs/build-support/rust/default-crate-overrides.nix b/pkgs/build-support/rust/default-crate-overrides.nix
index 1c4fe9daeada..d0e69ad698a8 100644
--- a/pkgs/build-support/rust/default-crate-overrides.nix
+++ b/pkgs/build-support/rust/default-crate-overrides.nix
@@ -16,18 +16,21 @@ in
};
libz-sys = attrs: {
- buildInputs = [ pkgconfig zlib ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ zlib ];
extraLinkFlags = ["-L${zlib.out}/lib"];
};
curl-sys = attrs: {
- buildInputs = [ pkgconfig zlib curl ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ zlib curl ];
propagatedBuildInputs = [ curl zlib ];
extraLinkFlags = ["-L${zlib.out}/lib"];
};
dbus = attrs: {
- buildInputs = [ pkgconfig dbus ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ dbus ];
};
foundationdb-sys = attrs: {
@@ -62,19 +65,23 @@ in
libgit2-sys = attrs: {
LIBGIT2_SYS_USE_PKG_CONFIG = true;
- buildInputs = [ pkgconfig openssl zlib libgit2 ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ openssl zlib libgit2 ];
};
libsqlite3-sys = attrs: {
- buildInputs = [ pkgconfig sqlite ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ sqlite ];
};
libssh2-sys = attrs: {
- buildInputs = [ pkgconfig openssl zlib libssh2 ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ openssl zlib libssh2 ];
};
libdbus-sys = attrs: {
- buildInputs = [ pkgconfig dbus ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ dbus ];
};
openssl = attrs: {
@@ -82,11 +89,13 @@ in
};
openssl-sys = attrs: {
- buildInputs = [ pkgconfig openssl ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ openssl ];
};
pq-sys = attr: {
- buildInputs = [ pkgconfig postgresql ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ postgresql ];
};
rink = attrs: {
@@ -103,7 +112,8 @@ in
};
thrussh-libsodium = attrs: {
- buildInputs = [ pkgconfig libsodium ];
+ nativeBuildInputs = [ pkgconfig ];
+ buildInputs = [ libsodium ];
};
xcb = attrs: {
diff --git a/pkgs/build-support/setup-hooks/install-shell-files.sh b/pkgs/build-support/setup-hooks/install-shell-files.sh
index e0ea1f7f30a7..194b408b1050 100644
--- a/pkgs/build-support/setup-hooks/install-shell-files.sh
+++ b/pkgs/build-support/setup-hooks/install-shell-files.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+# shellcheck shell=bash
# Setup hook for the `installShellFiles` package.
#
# Example usage in a derivation:
@@ -19,8 +19,8 @@
# installManPage <path> [...<path>]
#
# Each argument is checked for its man section suffix and installed into the appropriate
-# share/man<n>/ directory. The function returns an error if any paths don't have the man section
-# suffix (with optional .gz compression).
+# share/man/man<n>/ directory. The function returns an error if any paths don't have the man
+# section suffix (with optional .gz compression).
installManPage() {
local path
for path in "$@"; do
@@ -49,7 +49,7 @@ installManPage() {
done
}
-# installShellCompletion [--bash|--fish|--zsh] ([--name <name>] <path>)...
+# installShellCompletion [--cmd <name>] ([--bash|--fish|--zsh] [--name <name>] <path>)...
#
# Each path is installed into the appropriate directory for shell completions for the given shell.
# If one of `--bash`, `--fish`, or `--zsh` is given the path is assumed to belong to that shell.
@@ -61,9 +61,20 @@ installManPage() {
# If the shell completion needs to be renamed before installing the optional `--name <name>` flag
# may be given. Any name provided with this flag only applies to the next path.
#
+# If all shell completions need to be renamed before installing the optional `--cmd <name>` flag
+# may be given. This will synthesize a name for each file, unless overridden with an explicit
+# `--name` flag. For example, `--cmd foobar` will synthesize the name `_foobar` for zsh and
+# `foobar.bash` for bash.
+#
# For zsh completions, if the `--name` flag is not given, the path will be automatically renamed
# such that `foobar.zsh` becomes `_foobar`.
#
+# A path may be a named fd, such as produced by the bash construct `<(cmd)`. When using a named fd,
+# the shell type flag must be provided, and either the `--name` or `--cmd` flag must be provided.
+# This might look something like:
+#
+# installShellCompletion --zsh --name _foobar <($out/bin/foobar --zsh-completion)
+#
# This command accepts multiple shell flags in conjunction with multiple paths if you wish to
# install them all in one command:
#
@@ -76,9 +87,16 @@ installManPage() {
# installShellCompletion --fish --name foobar.fish share/completions.fish
# installShellCompletion --zsh --name _foobar share/completions.zsh
#
+# Or to use shell newline escaping to split a single invocation across multiple lines:
+#
+# installShellCompletion --cmd foobar \
+# --bash <($out/bin/foobar --bash-completion) \
+# --fish <($out/bin/foobar --fish-completion) \
+# --zsh <($out/bin/foobar --zsh-completion)
+#
# If any argument is `--` the remaining arguments will be treated as paths.
installShellCompletion() {
- local shell='' name='' retval=0 parseArgs=1 arg
+ local shell='' name='' cmdname='' retval=0 parseArgs=1 arg
while { arg=$1; shift; }; do
# Parse arguments
if (( parseArgs )); then
@@ -97,6 +115,17 @@ installShellCompletion() {
# treat `--name=foo` the same as `--name foo`
name=${arg#--name=}
continue;;
+ --cmd)
+ cmdname=$1
+ shift || {
+ echo 'installShellCompletion: error: --cmd flag expected an argument' >&2
+ return 1
+ }
+ continue;;
+ --cmd=*)
+ # treat `--cmd=foo` the same as `--cmd foo`
+ cmdname=${arg#--cmd=}
+ continue;;
--?*)
echo "installShellCompletion: warning: unknown flag ${arg%%=*}" >&2
retval=2
@@ -110,39 +139,67 @@ installShellCompletion() {
if (( "${NIX_DEBUG:-0}" >= 1 )); then
echo "installShellCompletion: installing $arg${name:+ as $name}"
fi
- # if we get here, this is a path
- # Identify shell
- local basename
- basename=$(stripHash "$arg")
+ # if we get here, this is a path or named pipe
+ # Identify shell and output name
local curShell=$shell
- if [[ -z "$curShell" ]]; then
- # auto-detect the shell
- case "$basename" in
- ?*.bash) curShell=bash;;
- ?*.fish) curShell=fish;;
- ?*.zsh) curShell=zsh;;
+ local outName=''
+ if [[ -z "$arg" ]]; then
+ echo "installShellCompletion: error: empty path is not allowed" >&2
+ return 1
+ elif [[ -p "$arg" ]]; then
+ # this is a named fd or fifo
+ if [[ -z "$curShell" ]]; then
+ echo "installShellCompletion: error: named pipe requires one of --bash, --fish, or --zsh" >&2
+ return 1
+ elif [[ -z "$name" && -z "$cmdname" ]]; then
+ echo "installShellCompletion: error: named pipe requires one of --cmd or --name" >&2
+ return 1
+ fi
+ else
+ # this is a path
+ local argbase
+ argbase=$(stripHash "$arg")
+ if [[ -z "$curShell" ]]; then
+ # auto-detect the shell
+ case "$argbase" in
+ ?*.bash) curShell=bash;;
+ ?*.fish) curShell=fish;;
+ ?*.zsh) curShell=zsh;;
+ *)
+ if [[ "$argbase" = _* && "$argbase" != *.* ]]; then
+ # probably zsh
+ echo "installShellCompletion: warning: assuming path \`$arg' is zsh; please specify with --zsh" >&2
+ curShell=zsh
+ else
+ echo "installShellCompletion: warning: unknown shell for path: $arg" >&2
+ retval=2
+ continue
+ fi;;
+ esac
+ fi
+ outName=$argbase
+ fi
+ # Identify output path
+ if [[ -n "$name" ]]; then
+ outName=$name
+ elif [[ -n "$cmdname" ]]; then
+ case "$curShell" in
+ bash|fish) outName=$cmdname.$curShell;;
+ zsh) outName=_$cmdname;;
*)
- if [[ "$basename" = _* && "$basename" != *.* ]]; then
- # probably zsh
- echo "installShellCompletion: warning: assuming path \`$arg' is zsh; please specify with --zsh" >&2
- curShell=zsh
- else
- echo "installShellCompletion: warning: unknown shell for path: $arg" >&2
- retval=2
- continue
- fi;;
+ # Our list of shells is out of sync with the flags we accept or extensions we detect.
+ echo 'installShellCompletion: internal error' >&2
+ return 1;;
esac
fi
- # Identify output path
- local outName sharePath
- outName=${name:-$basename}
+ local sharePath
case "$curShell" in
bash) sharePath=bash-completion/completions;;
fish) sharePath=fish/vendor_completions.d;;
zsh)
sharePath=zsh/site-functions
# only apply automatic renaming if we didn't have a manual rename
- if test -z "$name"; then
+ if [[ -z "$name" && -z "$cmdname" ]]; then
# convert a name like `foo.zsh` into `_foo`
outName=${outName%.zsh}
outName=_${outName#_}
@@ -153,8 +210,16 @@ installShellCompletion() {
return 1;;
esac
# Install file
- install -Dm644 -T "$arg" "${!outputBin:?}/share/$sharePath/$outName" || return
- # Clear the name, it only applies to one path
+ local outDir="${!outputBin:?}/share/$sharePath"
+ local outPath="$outDir/$outName"
+ if [[ -p "$arg" ]]; then
+ # install handles named pipes on NixOS but not on macOS
+ mkdir -p "$outDir" \
+ && cat "$arg" > "$outPath"
+ else
+ install -Dm644 -T "$arg" "$outPath"
+ fi || return
+ # Clear the per-path flags
name=
done
if [[ -n "$name" ]]; then
diff --git a/pkgs/build-support/setup-hooks/move-systemd-user-units.sh b/pkgs/build-support/setup-hooks/move-systemd-user-units.sh
new file mode 100755
index 000000000000..5963d87c7515
--- /dev/null
+++ b/pkgs/build-support/setup-hooks/move-systemd-user-units.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+# This setup hook, for each output, moves everything in
+# $output/lib/systemd/user to $output/share/systemd/user, and replaces
+# $output/lib/systemd/user with a symlink to
+# $output/share/systemd/user.
+
+fixupOutputHooks+=(_moveSystemdUserUnits)
+
+_moveSystemdUserUnits() {
+ if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then return; fi
+ if [ ! -e "${prefix:?}/lib/systemd/user" ]; then return; fi
+ local source="$prefix/lib/systemd/user"
+ local target="$prefix/share/systemd/user"
+ echo "moving $source/* to $target"
+ mkdir -p "$target"
+ (
+ shopt -s dotglob
+ for i in "$source"/*; do
+ mv "$i" "$target"
+ done
+ )
+ rmdir "$source"
+ ln -s "$target" "$source"
+}
diff --git a/pkgs/build-support/setup-hooks/validate-pkg-config.sh b/pkgs/build-support/setup-hooks/validate-pkg-config.sh
index 54fc9cc122ca..ada1b56760d6 100644
--- a/pkgs/build-support/setup-hooks/validate-pkg-config.sh
+++ b/pkgs/build-support/setup-hooks/validate-pkg-config.sh
@@ -3,9 +3,8 @@
fixupOutputHooks+=(_validatePkgConfig)
_validatePkgConfig() {
+ local bail=0
for pc in $(find "$prefix" -name '*.pc'); do
- local bail=0
-
# Do not fail immediately. It's nice to see all errors when
# there are multiple pkgconfig files.
if ! pkg-config --validate "$pc"; then
diff --git a/pkgs/build-support/singularity-tools/default.nix b/pkgs/build-support/singularity-tools/default.nix
index d937ec626682..4a54498d117c 100644
--- a/pkgs/build-support/singularity-tools/default.nix
+++ b/pkgs/build-support/singularity-tools/default.nix
@@ -7,7 +7,7 @@
, bash
, vmTools
, gawk
-, utillinux
+, util-linux
, runtimeShell
, e2fsprogs }:
@@ -47,7 +47,7 @@ rec {
runScriptFile = shellScript "run-script.sh" runScript;
result = vmTools.runInLinuxVM (
runCommand "singularity-image-${name}.img" {
- buildInputs = [ singularity e2fsprogs utillinux gawk ];
+ buildInputs = [ singularity e2fsprogs util-linux gawk ];
layerClosure = writeReferencesToFile layer;
preVM = vmTools.createEmptyImage {
size = diskSize;
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix
index 909cdc6da044..2f18e96e4ce2 100644
--- a/pkgs/build-support/vm/default.nix
+++ b/pkgs/build-support/vm/default.nix
@@ -151,7 +151,7 @@ rec {
# Set the system time from the hardware clock. Works around an
# apparent KVM > 1.5.2 bug.
- ${pkgs.utillinux}/bin/hwclock -s
+ ${pkgs.util-linux}/bin/hwclock -s
export NIX_STORE=${storeDir}
export NIX_BUILD_TOP=/tmp
@@ -270,7 +270,7 @@ rec {
defaultCreateRootFS = ''
mkdir /mnt
${e2fsprogs}/bin/mkfs.ext4 /dev/${hd}
- ${utillinux}/bin/mount -t ext4 /dev/${hd} /mnt
+ ${util-linux}/bin/mount -t ext4 /dev/${hd} /mnt
if test -e /mnt/.debug; then
exec ${bash}/bin/sh
@@ -317,7 +317,7 @@ rec {
with pkgs; runInLinuxVM (
stdenv.mkDerivation {
name = "extract-file";
- buildInputs = [ utillinux ];
+ buildInputs = [ util-linux ];
buildCommand = ''
ln -s ${kernel}/lib /lib
${kmod}/bin/modprobe loop
@@ -342,7 +342,7 @@ rec {
with pkgs; runInLinuxVM (
stdenv.mkDerivation {
name = "extract-file-mtd";
- buildInputs = [ utillinux mtdutils ];
+ buildInputs = [ util-linux mtdutils ];
buildCommand = ''
ln -s ${kernel}/lib /lib
${kmod}/bin/modprobe mtd
@@ -417,7 +417,7 @@ rec {
# Make the Nix store available in /mnt, because that's where the RPMs live.
mkdir -p /mnt${storeDir}
- ${utillinux}/bin/mount -o bind ${storeDir} /mnt${storeDir}
+ ${util-linux}/bin/mount -o bind ${storeDir} /mnt${storeDir}
# Newer distributions like Fedora 18 require /lib etc. to be
# symlinked to /usr.
@@ -427,7 +427,7 @@ rec {
ln -s /usr/sbin /mnt/sbin
ln -s /usr/lib /mnt/lib
ln -s /usr/lib64 /mnt/lib64
- ${utillinux}/bin/mount -t proc none /mnt/proc
+ ${util-linux}/bin/mount -t proc none /mnt/proc
''}
echo "unpacking RPMs..."
@@ -445,7 +445,7 @@ rec {
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
rpm --initdb
- ${utillinux}/bin/mount -o bind /tmp /mnt/tmp
+ ${util-linux}/bin/mount -o bind /tmp /mnt/tmp
echo "installing RPMs..."
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
@@ -456,8 +456,8 @@ rec {
rm /mnt/.debug
- ${utillinux}/bin/umount /mnt${storeDir} /mnt/tmp ${lib.optionalString unifiedSystemDir "/mnt/proc"}
- ${utillinux}/bin/umount /mnt
+ ${util-linux}/bin/umount /mnt${storeDir} /mnt/tmp ${lib.optionalString unifiedSystemDir "/mnt/proc"}
+ ${util-linux}/bin/umount /mnt
'';
passthru = { inherit fullName; };
@@ -587,9 +587,9 @@ rec {
# Make the Nix store available in /mnt, because that's where the .debs live.
mkdir -p /mnt/inst${storeDir}
- ${utillinux}/bin/mount -o bind ${storeDir} /mnt/inst${storeDir}
- ${utillinux}/bin/mount -o bind /proc /mnt/proc
- ${utillinux}/bin/mount -o bind /dev /mnt/dev
+ ${util-linux}/bin/mount -o bind ${storeDir} /mnt/inst${storeDir}
+ ${util-linux}/bin/mount -o bind /proc /mnt/proc
+ ${util-linux}/bin/mount -o bind /dev /mnt/dev
# Misc. files/directories assumed by various packages.
echo "initialising Dpkg DB..."
@@ -635,10 +635,10 @@ rec {
rm /mnt/.debug
- ${utillinux}/bin/umount /mnt/inst${storeDir}
- ${utillinux}/bin/umount /mnt/proc
- ${utillinux}/bin/umount /mnt/dev
- ${utillinux}/bin/umount /mnt
+ ${util-linux}/bin/umount /mnt/inst${storeDir}
+ ${util-linux}/bin/umount /mnt/proc
+ ${util-linux}/bin/umount /mnt/dev
+ ${util-linux}/bin/umount /mnt
'';
passthru = { inherit fullName; };
diff --git a/pkgs/build-support/wrapper-common/utils.bash b/pkgs/build-support/wrapper-common/utils.bash
index 8c4680a8e446..d164982b4345 100644
--- a/pkgs/build-support/wrapper-common/utils.bash
+++ b/pkgs/build-support/wrapper-common/utils.bash
@@ -69,9 +69,13 @@ badPath() {
# directory (including the build directory).
test \
"$p" != "/dev/null" -a \
- "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
- "${p:0:4}" != "/tmp" -a \
- "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
+ "${p#${NIX_STORE}}" = "$p" -a \
+ "${p#${NIX_BUILD_TOP}}" = "$p" -a \
+ "${p#/tmp}" = "$p" -a \
+ "${p#${TMP:-/tmp}}" = "$p" -a \
+ "${p#${TMPDIR:-/tmp}}" = "$p" -a \
+ "${p#${TEMP:-/tmp}}" = "$p" -a \
+ "${p#${TEMPDIR:-/tmp}}" = "$p"
}
expandResponseParams() {
diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix
index 495a56b41974..9c709921d210 100644
--- a/pkgs/build-support/writers/default.nix
+++ b/pkgs/build-support/writers/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib }:
+{ pkgs, lib, gawk, gnused, gixy }:
with lib;
rec {
@@ -219,10 +219,11 @@ rec {
writeNginxConfig = name: text: pkgs.runCommandLocal name {
inherit text;
passAsFile = [ "text" ];
+ nativeBuildInputs = [ gawk gnused gixy ];
} /* sh */ ''
# nginx-config-formatter has an error - https://github.com/1connect/nginx-config-formatter/issues/16
- ${pkgs.gawk}/bin/awk -f ${awkFormatNginx} "$textPath" | ${pkgs.gnused}/bin/sed '/^\s*$/d' > $out
- ${pkgs.gixy}/bin/gixy $out
+ awk -f ${awkFormatNginx} "$textPath" | sed '/^\s*$/d' > $out
+ gixy $out
'';
# writePerl takes a name an attributeset with libraries and some perl sourcecode and