push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
# shellcheck shell=bash disable=SC2154,SC2164
cargoBuildHook() {
echo "Executing cargoBuildHook"
runHook preBuild
# Let stdenv handle stripping, for consistency and to not break
# separateDebugInfo.
export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false
if [ -n "${buildAndTestSubdir-}" ]; then
# ensure the output doesn't end up in the subdirectory
CARGO_TARGET_DIR="$(pwd)/target"
export CARGO_TARGET_DIR
pushd "${buildAndTestSubdir}"
fi
local flagsArray=(
"-j" "$NIX_BUILD_CORES"
"--target" "@rustcTargetSpec@"
"--offline"
)
if [ "${cargoBuildType}" != "debug" ]; then
flagsArray+=("--profile" "${cargoBuildType}")
fi
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
flagsArray+=("--no-default-features")
fi
if [ -n "${cargoBuildFeatures-}" ]; then
flagsArray+=("--features=$(concatStringsSep "," cargoBuildFeatures)")
fi
concatTo flagsArray cargoBuildFlags
echoCmd 'cargoBuildHook flags' "${flagsArray[@]}"
@setEnv@ cargo build "${flagsArray[@]}"
if [ -n "${buildAndTestSubdir-}" ]; then
popd
fi
runHook postBuild
echo "Finished cargoBuildHook"
}
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
buildPhase=cargoBuildHook
fi

View File

@@ -0,0 +1,53 @@
# shellcheck shell=bash disable=SC2154,SC2164
cargoCheckHook() {
echo "Executing cargoCheckHook"
runHook preCheck
if [[ -n "${buildAndTestSubdir-}" ]]; then
pushd "${buildAndTestSubdir}"
fi
local flagsArray=("-j" "$NIX_BUILD_CORES")
export RUST_TEST_THREADS=$NIX_BUILD_CORES
if [[ ! -z ${dontUseCargoParallelTests-} ]]; then
RUST_TEST_THREADS=1
fi
if [ "${cargoCheckType}" != "debug" ]; then
flagsArray+=("--profile" "${cargoCheckType}")
fi
if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then
flagsArray+=("--no-default-features")
fi
if [ -n "${cargoCheckFeatures-}" ]; then
flagsArray+=("--features=$(concatStringsSep "," cargoCheckFeatures)")
fi
flagsArray+=(
"--target" "@rustcTargetSpec@"
"--offline"
)
prependToVar checkFlags "--"
concatTo flagsArray cargoTestFlags checkFlags checkFlagsArray
echoCmd 'cargoCheckHook flags' "${flagsArray[@]}"
@setEnv@ cargo test "${flagsArray[@]}"
if [[ -n "${buildAndTestSubdir-}" ]]; then
popd
fi
echo "Finished cargoCheckHook"
runHook postCheck
}
if [ -z "${dontCargoCheck-}" ] && [ -z "${checkPhase-}" ]; then
checkPhase=cargoCheckHook
fi

View File

@@ -0,0 +1,54 @@
cargoInstallPostBuildHook() {
echo "Executing cargoInstallPostBuildHook"
releaseDir=target/@targetSubdirectory@/$cargoBuildType
tmpDir="${releaseDir}-tmp";
mkdir -p $tmpDir
cp -r ${releaseDir}/* $tmpDir/
bins=$(find $tmpDir \
-maxdepth 1 \
-type f \
-executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \))
echo "Finished cargoInstallPostBuildHook"
}
cargoInstallHook() {
echo "Executing cargoInstallHook"
runHook preInstall
# rename the output dir to a architecture independent one
releaseDir=target/@targetSubdirectory@/$cargoBuildType
tmpDir="${releaseDir}-tmp";
mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep "${tmpDir}$")
for target in "${targets[@]}"; do
rm -rf "$target/../../${cargoBuildType}"
ln -srf "$target" "$target/../../"
done
mkdir -p $out/bin $out/lib
xargs -r cp -t $out/bin <<< $bins
find $tmpDir \
-maxdepth 1 \
-regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \
-print0 | xargs -r -0 cp -t $out/lib
# If present, copy any .dSYM directories for debugging on darwin
# https://github.com/NixOS/nixpkgs/issues/330036
find "${releaseDir}" -maxdepth 1 -name '*.dSYM' -exec cp -RLt $out/bin/ {} +
rmdir --ignore-fail-on-non-empty $out/lib $out/bin
runHook postInstall
echo "Finished cargoInstallHook"
}
if [ -z "${dontCargoInstall-}" ] && [ -z "${installPhase-}" ]; then
installPhase=cargoInstallHook
postBuildHooks+=(cargoInstallPostBuildHook)
fi

View File

@@ -0,0 +1,52 @@
# shellcheck shell=bash disable=SC2154,SC2164
cargoNextestHook() {
echo "Executing cargoNextestHook"
runHook preCheck
if [[ -n "${buildAndTestSubdir-}" ]]; then
pushd "${buildAndTestSubdir}"
fi
local flagsArray=(
"--target" "@rustcTargetSpec@"
"--offline"
)
if [[ -z ${dontUseCargoParallelTests-} ]]; then
flagsArray+=("-j" "$NIX_BUILD_CORES")
else
flagsArray+=("-j" "1")
fi
if [ "${cargoCheckType}" != "debug" ]; then
flagsArray+=("--cargo-profile" "${cargoCheckType}")
fi
if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then
flagsArray+=("--no-default-features")
fi
if [ -n "${cargoCheckFeatures-}" ]; then
flagsArray+=("--features=$(concatStringsSep "," cargoCheckFeatures)")
fi
prependToVar checkFlags "--"
concatTo flagsArray cargoTestFlags checkFlags checkFlagsArray
echoCmd 'cargoNextestHook flags' "${flagsArray[@]}"
cargo nextest run "${flagsArray[@]}"
if [[ -n "${buildAndTestSubdir-}" ]]; then
popd
fi
echo "Finished cargoNextestHook"
runHook postCheck
}
if [ -z "${dontCargoCheck-}" ] && [ -z "${checkPhase-}" ]; then
checkPhase=cargoNextestHook
fi

View File

@@ -0,0 +1,93 @@
cargoSetupPostUnpackHook() {
echo "Executing cargoSetupPostUnpackHook"
# Some cargo builds include build hooks that modify their own vendor
# dependencies. This copies the vendor directory into the build tree and makes
# it writable. If we're using a tarball, the unpackFile hook already handles
# this for us automatically.
if [ -z $cargoVendorDir ]; then
if [ -d "$cargoDeps" ]; then
local dest=$(stripHash "$cargoDeps")
cp -Lr --reflink=auto -- "$cargoDeps" "$dest"
chmod -R +644 -- "$dest"
else
unpackFile "$cargoDeps"
fi
export cargoDepsCopy="$(realpath "$(stripHash $cargoDeps)")"
else
cargoDepsCopy="$(realpath "$(pwd)/$sourceRoot/${cargoRoot:+$cargoRoot/}${cargoVendorDir}")"
fi
if [ ! -d .cargo ]; then
mkdir .cargo
fi
config="$cargoDepsCopy/.cargo/config.toml"
if [[ ! -e $config ]]; then
config=@defaultConfig@
fi;
tmp_config=$(mktemp)
substitute $config $tmp_config \
--subst-var-by vendor "$cargoDepsCopy"
cat ${tmp_config} >> .cargo/config.toml
cat >> .cargo/config.toml <<'EOF'
@cargoConfig@
EOF
echo "Finished cargoSetupPostUnpackHook"
}
# After unpacking and applying patches, check that the Cargo.lock matches our
# src package. Note that we do this after the patchPhase, because the
# patchPhase may create the Cargo.lock if upstream has not shipped one.
cargoSetupPostPatchHook() {
echo "Executing cargoSetupPostPatchHook"
cargoDepsLockfile="$cargoDepsCopy/Cargo.lock"
srcLockfile="$(pwd)/${cargoRoot:+$cargoRoot/}Cargo.lock"
echo "Validating consistency between $srcLockfile and $cargoDepsLockfile"
if ! @diff@ $srcLockfile $cargoDepsLockfile; then
# If the diff failed, first double-check that the file exists, so we can
# give a friendlier error msg.
if ! [ -e $srcLockfile ]; then
echo "ERROR: Missing Cargo.lock from src. Expected to find it at: $srcLockfile"
echo "Hint: You can use the cargoPatches attribute to add a Cargo.lock manually to the build."
exit 1
fi
if ! [ -e $cargoDepsLockfile ]; then
echo "ERROR: Missing lockfile from cargo vendor. Expected to find it at: $cargoDepsLockfile"
exit 1
fi
echo
echo "ERROR: cargoHash or cargoSha256 is out of date"
echo
echo "Cargo.lock is not the same in $cargoDepsCopy"
echo
echo "To fix the issue:"
echo '1. Set cargoHash/cargoSha256 to an empty string: `cargoHash = "";`'
echo '2. Build the derivation and wait for it to fail with a hash mismatch'
echo '3. Copy the "got: sha256-..." value back into the cargoHash field'
echo ' You should have: cargoHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";'
echo
exit 1
fi
unset cargoDepsCopy
echo "Finished cargoSetupPostPatchHook"
}
if [ -z "${dontCargoSetupPostUnpack-}" ]; then
postUnpackHooks+=(cargoSetupPostUnpackHook)
fi
if [ -z ${cargoVendorDir-} ]; then
postPatchHooks+=(cargoSetupPostPatchHook)
fi

View File

@@ -0,0 +1,137 @@
{
cargo-nextest,
clang,
diffutils,
lib,
makeSetupHook,
rust,
stdenv,
pkgsHostTarget,
pkgsTargetTarget,
# This confusingly-named parameter indicates the *subdirectory of
# `target/` from which to copy the build artifacts. It is derived
# from a stdenv platform (or a JSON file).
target ? stdenv.targetPlatform.rust.cargoShortTarget,
tests,
pkgsCross,
}:
{
cargoBuildHook = makeSetupHook {
name = "cargo-build-hook.sh";
substitutions = {
inherit (stdenv.targetPlatform.rust) rustcTargetSpec;
inherit (rust.envVars) setEnv;
};
passthru.tests = {
test = tests.rust-hooks.cargoBuildHook;
}
// lib.optionalAttrs (stdenv.isLinux) {
testCross = pkgsCross.riscv64.tests.rust-hooks.cargoBuildHook;
};
} ./cargo-build-hook.sh;
cargoCheckHook = makeSetupHook {
name = "cargo-check-hook.sh";
substitutions = {
inherit (stdenv.targetPlatform.rust) rustcTargetSpec;
inherit (rust.envVars) setEnv;
};
passthru.tests = {
test = tests.rust-hooks.cargoCheckHook;
}
// lib.optionalAttrs (stdenv.isLinux) {
testCross = pkgsCross.riscv64.tests.rust-hooks.cargoCheckHook;
};
} ./cargo-check-hook.sh;
cargoInstallHook = makeSetupHook {
name = "cargo-install-hook.sh";
substitutions = {
targetSubdirectory = target;
};
passthru.tests = {
test = tests.rust-hooks.cargoInstallHook;
}
// lib.optionalAttrs (stdenv.isLinux) {
testCross = pkgsCross.riscv64.tests.rust-hooks.cargoInstallHook;
};
} ./cargo-install-hook.sh;
cargoNextestHook = makeSetupHook {
name = "cargo-nextest-hook.sh";
propagatedBuildInputs = [ cargo-nextest ];
substitutions = {
inherit (stdenv.targetPlatform.rust) rustcTargetSpec;
};
passthru.tests = {
test = tests.rust-hooks.cargoNextestHook;
}
// lib.optionalAttrs (stdenv.isLinux) {
testCross = pkgsCross.riscv64.tests.rust-hooks.cargoNextestHook;
};
} ./cargo-nextest-hook.sh;
cargoSetupHook = makeSetupHook {
name = "cargo-setup-hook.sh";
propagatedBuildInputs = [ ];
substitutions = {
defaultConfig = ../fetchcargo-default-config.toml;
# Specify the stdenv's `diff` by abspath to ensure that the user's build
# inputs do not cause us to find the wrong `diff`.
diff = "${lib.getBin diffutils}/bin/diff";
cargoConfig =
lib.optionalString (stdenv.hostPlatform.config != stdenv.targetPlatform.config) ''
[target."${stdenv.targetPlatform.rust.rustcTarget}"]
"linker" = "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc"
"rustflags" = [ ${
lib.concatStringsSep ", " (
[
''"-Ctarget-feature=${if stdenv.targetPlatform.isStatic then "+" else "-"}crt-static"''
]
++ lib.optional (!stdenv.targetPlatform.isx86_32) ''"-Cforce-frame-pointers=yes"''
)
} ]
''
+ ''
[target."${stdenv.hostPlatform.rust.rustcTarget}"]
"linker" = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"rustflags" = [ ${
lib.optionalString (!stdenv.hostPlatform.isx86_32) ''"-Cforce-frame-pointers=yes"''
} ]
'';
};
passthru.tests = {
test = tests.rust-hooks.cargoSetupHook;
}
// lib.optionalAttrs (stdenv.isLinux) {
testCross = pkgsCross.riscv64.tests.rust-hooks.cargoSetupHook;
};
} ./cargo-setup-hook.sh;
maturinBuildHook = makeSetupHook {
name = "maturin-build-hook.sh";
propagatedBuildInputs = [
pkgsHostTarget.maturin
pkgsHostTarget.cargo
pkgsHostTarget.rustc
];
substitutions = {
inherit (stdenv.targetPlatform.rust) rustcTargetSpec;
inherit (rust.envVars) setEnv;
};
} ./maturin-build-hook.sh;
bindgenHook = makeSetupHook {
name = "rust-bindgen-hook";
substitutions = {
libclang = (lib.getLib clang.cc);
inherit clang;
};
} ./rust-bindgen-hook.sh;
}

View File

@@ -0,0 +1,46 @@
# shellcheck shell=bash disable=SC2154,SC2164
maturinBuildHook() {
echo "Executing maturinBuildHook"
runHook preBuild
# Put the wheel to dist/ so that regular Python tooling can find it.
local dist="$PWD/dist"
if [ -n "${buildAndTestSubdir-}" ]; then
pushd "${buildAndTestSubdir}"
fi
# This is a huge hack, but it's the least invasive way
# to get the required interpreter name for maturin.
local interpreter_path="$(command -v python3 || command -v pypy3)"
local interpreter_name="$($interpreter_path -c 'import os; import sysconfig; print(os.path.basename(sysconfig.get_config_var('\''INCLUDEPY'\'')))')"
local flagsArray=(
"--jobs=$NIX_BUILD_CORES"
"--offline"
"--target" "@rustcTargetSpec@"
"--manylinux" "off"
"--strip"
"--release"
"--out" "$dist"
"--interpreter" "$interpreter_name"
)
concatTo flagsArray maturinBuildFlags
echoCmd 'maturinBuildHook flags' "${flagsArray[@]}"
@setEnv@ maturin build "${flagsArray[@]}"
if [ -n "${buildAndTestSubdir-}" ]; then
popd
fi
# These are python build hooks and may depend on ./dist
runHook postBuild
echo "Finished maturinBuildHook"
}
buildPhase=maturinBuildHook

View File

@@ -0,0 +1,13 @@
# populates LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS for rust projects that
# depend on the bindgen crate
# if you modify this, you probably also need to modify the wrapper for the cli
# of bindgen in pkgs/development/tools/rust/bindgen/wrapper.sh
populateBindgenEnv () {
export LIBCLANG_PATH=@libclang@/lib
BINDGEN_EXTRA_CLANG_ARGS="$(< @clang@/nix-support/cc-cflags) $(< @clang@/nix-support/libc-cflags) $(< @clang@/nix-support/libcxx-cxxflags) $NIX_CFLAGS_COMPILE"
export BINDGEN_EXTRA_CLANG_ARGS
}
postHook="${postHook:-}"$'\n'"populateBindgenEnv"$'\n'

View File

@@ -0,0 +1,104 @@
{
rustPlatform,
stdenv,
cargo,
}:
{
/*
test each hook individually, to make sure that:
- each hook works properly outside of buildRustPackage
- each hook is usable independently from each other
*/
cargoSetupHook = stdenv.mkDerivation {
name = "test-cargoSetupHook";
src = ./example-rust-project;
cargoVendorDir = "hello";
nativeBuildInputs = [
rustPlatform.cargoSetupHook
cargo
];
buildPhase = ''
cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
'';
installPhase = ''
mkdir -p $out/bin
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
'';
};
cargoBuildHook = stdenv.mkDerivation {
name = "test-cargoBuildHook";
src = ./example-rust-project;
cargoBuildType = "release";
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
"${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
nativeBuildInputs = [
rustPlatform.cargoBuildHook
cargo
];
installPhase = ''
mkdir -p $out/bin
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
'';
};
cargoInstallHook = stdenv.mkDerivation {
name = "test-cargoInstallHook";
src = ./example-rust-project;
cargoBuildType = "release";
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
"${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
nativeBuildInputs = [
rustPlatform.cargoInstallHook
cargo
];
buildPhase = ''
cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
runHook postBuild
'';
};
cargoCheckHook = stdenv.mkDerivation {
name = "test-cargoCheckHook";
src = ./example-rust-project;
cargoBuildType = "release";
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
"${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
nativeBuildInputs = [
rustPlatform.cargoCheckHook
cargo
];
buildPhase = ''
cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
runHook postBuild
'';
installPhase = ''
mkdir -p $out/bin
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
'';
cargoCheckType = "release";
doCheck = true;
};
cargoNextestHook = stdenv.mkDerivation {
name = "test-cargoNextestHook";
src = ./example-rust-project;
cargoBuildType = "release";
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" =
"${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
nativeBuildInputs = [
rustPlatform.cargoNextestHook
cargo
];
buildPhase = ''
cargo build --profile release --target ${stdenv.hostPlatform.rust.rustcTarget}
runHook postBuild
'';
installPhase = ''
mkdir -p $out/bin
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/hello $out/bin/
'';
cargoCheckType = "release";
doCheck = true;
};
}

View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "hello"
version = "0.1.0"

View File

@@ -0,0 +1,6 @@
[package]
name = "hello"
version = "0.1.0"
edition = "2021"
[dependencies]

View File

@@ -0,0 +1,3 @@
pub fn hello() -> &'static str {
return "Hello, world!";
}

View File

@@ -0,0 +1 @@
pub mod hello;

View File

@@ -0,0 +1,5 @@
mod hello;
fn main() {
println!("{}", hello::hello());
}

View File

@@ -0,0 +1,6 @@
use hello::hello;
#[test]
fn test_hello() {
assert_eq!(hello::hello(), "Hello, world!");
}