packaging: set CARGO_HOME

single-user builds have a writable home directory in the build sandbox,
and the test suite does not like cargo writing anything into there. the
impact of this seems to be localized to f1 (at least on linux), but not
letting cargo write into the homedir is easy enough to do. nixpkgs also
does something much like this when compiling rustc, so we're not alone.
(it also seems that nixpkgs intended to do this for all rustc users but
broke it at some point in the past. some packages set CARGO_HOME in the
same way we do, possibly because they've had exactly the same problems)

fixes #1251

Change-Id: Ie17a0677ef09bb076ef6295bb590a0895924434e
This commit is contained in:
eldritch horrors
2026-07-11 12:11:49 +00:00
parent 3b286bbd62
commit 8294860ccf
+8
View File
@@ -467,6 +467,14 @@ stdenv.mkDerivation (finalAttrs: {
buildPackages.clangStdenv.cc
];
# single-user builds fail because cargo can touch the derivation $HOME, which then in
# turn breaks the test suite (cf https://git.lix.systems/lix-project/lix/issues/1251)
prePatch = ''
if [[ -z ''${IN_NIX_SHELL-} && -z ''${CARGO_HOME-} ]]; then
export CARGO_HOME=$TMPDIR/.cargo
fi
'';
nativeBuildInputs = [
rustPlatform.cargoSetupHook
finalAttrs.lixPythonForBuild