From 8294860ccf52bec355072ad489af608ef25a7331 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 11 Jul 2026 13:22:10 +0200 Subject: [PATCH] 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 --- package.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package.nix b/package.nix index 290498629..8d5b94455 100644 --- a/package.nix +++ b/package.nix @@ -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