From 62d4ca6101ac9644331c4d7edfb408569c6ed86a Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 21:50:04 +0100 Subject: [PATCH 01/14] build-support: update `addBinToPathHook` hook --- pkgs/build-support/setup-hooks/add-bin-to-path.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/setup-hooks/add-bin-to-path.sh b/pkgs/build-support/setup-hooks/add-bin-to-path.sh index 308c2706fd05..375a544dc6a4 100644 --- a/pkgs/build-support/setup-hooks/add-bin-to-path.sh +++ b/pkgs/build-support/setup-hooks/add-bin-to-path.sh @@ -5,10 +5,8 @@ export PATH addBinToPath () { # shellcheck disable=SC2154 - if [ -d "$out/bin" ]; then - PATH="$out/bin:$PATH" - export PATH - fi + PATH="$out/bin:$PATH" + export PATH } # shellcheck disable=SC2154 From ce1e95c45f3db07164daa7a4e80597a4c1bdf66c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 18:57:53 +0100 Subject: [PATCH 02/14] awscli2: use `addBinToPathHook` and `writableTmpDirAsHomeHook` --- pkgs/by-name/aw/awscli2/package.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/aw/awscli2/package.nix b/pkgs/by-name/aw/awscli2/package.nix index aa3a114c9d32..6eace0a32db7 100644 --- a/pkgs/by-name/aw/awscli2/package.nix +++ b/pkgs/by-name/aw/awscli2/package.nix @@ -10,6 +10,8 @@ nix-update-script, testers, awscli2, + addBinToPathHook, + writableTmpDirAsHomeHook, }: let @@ -121,9 +123,11 @@ py.pkgs.buildPythonApplication rec { ]; nativeCheckInputs = with py.pkgs; [ + addBinToPathHook jsonschema mock pytestCheckHook + writableTmpDirAsHomeHook ]; postInstall = @@ -136,11 +140,6 @@ py.pkgs.buildPythonApplication rec { rm $out/bin/aws.cmd ''; - preCheck = '' - export PATH=$PATH:$out/bin - export HOME=$(mktemp -d) - ''; - # Propagating dependencies leaks them through $PYTHONPATH which causes issues # when used in nix-shell. postFixup = '' From e28bd6045501d1a9e2d16bb32bb0a7978364628d Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:34:45 +0100 Subject: [PATCH 03/14] meli: use `writableTmpDirAsHomeHook` --- pkgs/by-name/me/meli/package.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/me/meli/package.nix b/pkgs/by-name/me/meli/package.nix index 7640e4813d6c..a9f17fa67183 100644 --- a/pkgs/by-name/me/meli/package.nix +++ b/pkgs/by-name/me/meli/package.nix @@ -12,6 +12,7 @@ mandoc, rustfmt, file, + writableTmpDirAsHomeHook, # build inputs openssl, @@ -58,6 +59,7 @@ rustPlatform.buildRustPackage rec { nativeCheckInputs = [ file gnum4 + writableTmpDirAsHomeHook ]; postInstall = '' @@ -68,10 +70,6 @@ rustPlatform.buildRustPackage rec { --prefix PATH : ${lib.makeBinPath [ gnum4 ]} ''; - preCheck = '' - export HOME=$(mktemp -d) - ''; - checkFlags = [ "--skip=test_cli_subcommands" # panicking due to sandbox ]; From 6e7356cb06547e2faf65fbf64d7075f366c978a3 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:35:10 +0100 Subject: [PATCH 04/14] pylyzer: use `writableTmpDirAsHomeHook` --- pkgs/by-name/py/pylyzer/package.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/py/pylyzer/package.nix b/pkgs/by-name/py/pylyzer/package.nix index f413e1c583b8..2d877f671de6 100644 --- a/pkgs/by-name/py/pylyzer/package.nix +++ b/pkgs/by-name/py/pylyzer/package.nix @@ -3,12 +3,13 @@ stdenv, rustPlatform, fetchFromGitHub, - git, + gitMinimal, python3, makeWrapper, writeScriptBin, versionCheckHook, nix-update-script, + writableTmpDirAsHomeHook, }: rustPlatform.buildRustPackage rec { @@ -26,19 +27,16 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-mi4pCYA0dQnv3MIpZxVVY0qLdIts/qvxS4og0Tyxk3w="; nativeBuildInputs = [ - git + gitMinimal python3 makeWrapper + writableTmpDirAsHomeHook ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ (writeScriptBin "diskutil" "") ]; buildInputs = [ python3 ]; - preBuild = '' - export HOME=$(mktemp -d) - ''; - postInstall = '' mkdir -p $out/lib cp -r $HOME/.erg/ $out/lib/erg From 72cf3eb5ac172b5a0dbaf54cb08f12a36f9e698d Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:35:41 +0100 Subject: [PATCH 05/14] shopware-cli: minor cleanup --- pkgs/by-name/sh/shopware-cli/package.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/by-name/sh/shopware-cli/package.nix b/pkgs/by-name/sh/shopware-cli/package.nix index fac9a4e22a0a..16a8458e7086 100644 --- a/pkgs/by-name/sh/shopware-cli/package.nix +++ b/pkgs/by-name/sh/shopware-cli/package.nix @@ -14,7 +14,7 @@ buildGoModule rec { src = fetchFromGitHub { repo = "shopware-cli"; owner = "FriendsOfShopware"; - rev = version; + tag = version; hash = "sha256-nFjm1z7QXuUkZ4sVRY0KdFpo0SXBTmJNA28YJpAyG2w="; }; @@ -30,7 +30,6 @@ buildGoModule rec { vendorHash = "sha256-7DVC68tKoEwaTbF6Lkv1Ib1imZojTPW3G/QS3W6N8ys="; postInstall = '' - export HOME="$(mktemp -d)" installShellCompletion --cmd shopware-cli \ --bash <($out/bin/shopware-cli completion bash) \ --zsh <($out/bin/shopware-cli completion zsh) \ From f75606e0cbb016e3e82f99a7df72b8dc874ddd22 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:35:58 +0100 Subject: [PATCH 06/14] snapcraft: use `writableTmpDirAsHomeHook` --- pkgs/by-name/sn/snapcraft/package.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/sn/snapcraft/package.nix b/pkgs/by-name/sn/snapcraft/package.nix index c7927f854cdf..02c86328e71b 100644 --- a/pkgs/by-name/sn/snapcraft/package.nix +++ b/pkgs/by-name/sn/snapcraft/package.nix @@ -1,6 +1,6 @@ { fetchFromGitHub, - git, + gitMinimal, glibc, lib, makeWrapper, @@ -8,6 +8,7 @@ python3Packages, squashfsTools, stdenv, + writableTmpDirAsHomeHook, }: python3Packages.buildPythonApplication rec { @@ -138,17 +139,13 @@ python3Packages.buildPythonApplication rec { pytestCheckHook responses setuptools + writableTmpDirAsHomeHook ] ++ [ - git + gitMinimal squashfsTools ]; - preCheck = '' - mkdir -p check-phase - export HOME="$(pwd)/check-phase" - ''; - pytestFlagsArray = [ "tests/unit" ]; disabledTests = [ From e3d1fe03ed006725039cdddb2ca9a222e837f3aa Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:38:26 +0100 Subject: [PATCH 07/14] menulibre: use `writableTmpDirAsHomeHook` --- pkgs/by-name/me/menulibre/package.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/me/menulibre/package.nix b/pkgs/by-name/me/menulibre/package.nix index 530d0f8f7ab6..a5a9e2e8bb87 100644 --- a/pkgs/by-name/me/menulibre/package.nix +++ b/pkgs/by-name/me/menulibre/package.nix @@ -10,6 +10,7 @@ nix-update-script, testers, menulibre, + writableTmpDirAsHomeHook, }: python3Packages.buildPythonApplication rec { @@ -19,7 +20,7 @@ python3Packages.buildPythonApplication rec { src = fetchFromGitHub { owner = "bluesabre"; repo = "menulibre"; - rev = "menulibre-${version}"; + tag = "menulibre-${version}"; hash = "sha256-IfsuOYP/H3r1GDWMVVSBfYvQS+01VJaAlZu+c05geWg="; }; @@ -35,6 +36,7 @@ python3Packages.buildPythonApplication rec { intltool gobject-introspection wrapGAppsHook3 + writableTmpDirAsHomeHook ]; postPatch = '' @@ -43,10 +45,6 @@ python3Packages.buildPythonApplication rec { --replace-fail 'update_desktop_file(desktop_file, script_path)' "" ''; - preBuild = '' - export HOME=$TMPDIR - ''; - passthru = { updateScript = nix-update-script { }; tests.version = testers.testVersion { From 57e5e286789feae360134e575c04d0c18ee7eb28 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:42:53 +0100 Subject: [PATCH 08/14] hedgedoc: use `writableTmpDirAsHomeHook` --- pkgs/by-name/he/hedgedoc/package.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/he/hedgedoc/package.nix b/pkgs/by-name/he/hedgedoc/package.nix index 01b4b38e9b8d..d22920bd0175 100644 --- a/pkgs/by-name/he/hedgedoc/package.nix +++ b/pkgs/by-name/he/hedgedoc/package.nix @@ -9,6 +9,7 @@ nodejs, python3, nixosTests, + writableTmpDirAsHomeHook, }: let @@ -17,7 +18,7 @@ let src = fetchFromGitHub { owner = "hedgedoc"; repo = "hedgedoc"; - rev = version; + tag = version; hash = "sha256-cRIpcoD9WzLYxKYpkvhRxUmeyJR5z2QyqApzWvQND+s="; }; @@ -31,10 +32,10 @@ let gitMinimal # needed to download git dependencies nodejs # needed for npm to download git dependencies yarn + writableTmpDirAsHomeHook ]; buildPhase = '' - export HOME=$(mktemp -d) yarn config set enableTelemetry 0 yarn config set cacheFolder $out yarn config set --json supportedArchitectures.os '[ "linux" ]' From 3f1c6f0155d3958d7a91f2f58eb54d5319ad5658 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:45:16 +0100 Subject: [PATCH 09/14] hatch: use `writableTmpDirAsHomeHook` --- pkgs/by-name/ha/hatch/package.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/ha/hatch/package.nix b/pkgs/by-name/ha/hatch/package.nix index 5a5aff9e0473..215d6a45f1d0 100644 --- a/pkgs/by-name/ha/hatch/package.nix +++ b/pkgs/by-name/ha/hatch/package.nix @@ -7,6 +7,7 @@ git, cargo, versionCheckHook, + writableTmpDirAsHomeHook, darwin, nix-update-script, }: @@ -63,6 +64,7 @@ python3Packages.buildPythonApplication rec { ++ [ cargo versionCheckHook + writableTmpDirAsHomeHook ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.ps @@ -70,10 +72,6 @@ python3Packages.buildPythonApplication rec { versionCheckProgramArg = [ "--version" ]; - preCheck = '' - export HOME=$(mktemp -d); - ''; - pytestFlagsArray = [ # AssertionError on the version metadata From 15fa6bec0186947548e98c895eacf6a2f47a4bbb Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 20:52:16 +0100 Subject: [PATCH 10/14] aws-shell: use `writableTmpDirAsHomeHook` --- pkgs/by-name/aw/aws-shell/package.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/aw/aws-shell/package.nix b/pkgs/by-name/aw/aws-shell/package.nix index 5b1222f5ef84..ed7646e6446c 100644 --- a/pkgs/by-name/aw/aws-shell/package.nix +++ b/pkgs/by-name/aw/aws-shell/package.nix @@ -3,6 +3,7 @@ lib, fetchFromGitHub, awscli, + writableTmpDirAsHomeHook, }: python3Packages.buildPythonApplication rec { @@ -38,12 +39,9 @@ python3Packages.buildPythonApplication rec { nativeCheckInputs = with python3Packages; [ pytestCheckHook + writableTmpDirAsHomeHook ]; - preCheck = '' - export HOME=$(mktemp -d) - ''; - meta = { homepage = "https://github.com/awslabs/aws-shell"; description = "Integrated shell for working with the AWS CLI"; From 9322094a231eefd9089e238216698eb7c583e5b4 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 21:06:40 +0100 Subject: [PATCH 11/14] amp: use `writableTmpDirAsHomeHook` --- pkgs/by-name/am/amp/package.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/am/amp/package.nix b/pkgs/by-name/am/amp/package.nix index 2d0890b63d67..cd1e8eb7ca32 100644 --- a/pkgs/by-name/am/amp/package.nix +++ b/pkgs/by-name/am/amp/package.nix @@ -11,6 +11,7 @@ libgit2, darwin, curl, + writableTmpDirAsHomeHook, }: rustPlatform.buildRustPackage rec { @@ -20,7 +21,7 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "jmacdonald"; repo = "amp"; - rev = version; + tag = version; hash = "sha256-xNadwz2agPbxvgUqrUf1+KsWTmeNh8hJIWcNwTzzM/M="; }; @@ -48,8 +49,9 @@ rustPlatform.buildRustPackage rec { ] ); - # Tests need to write to the theme directory in HOME. - preCheck = "export HOME=`mktemp -d`"; + nativeCheckInputs = [ + writableTmpDirAsHomeHook + ]; meta = { description = "Modern text editor inspired by Vim"; From 6f6f5736b38a0c6573aed4ac501876c3a9afb75c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 21:09:21 +0100 Subject: [PATCH 12/14] apx: use `writableTmpDirAsHomeHook` --- pkgs/by-name/ap/apx/package.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/ap/apx/package.nix b/pkgs/by-name/ap/apx/package.nix index b60e70a45c51..5b9d3be524db 100644 --- a/pkgs/by-name/ap/apx/package.nix +++ b/pkgs/by-name/ap/apx/package.nix @@ -5,6 +5,7 @@ installShellFiles, distrobox, podman, + writableTmpDirAsHomeHook, }: buildGoModule rec { @@ -14,7 +15,7 @@ buildGoModule rec { src = fetchFromGitHub { owner = "Vanilla-OS"; repo = "apx"; - rev = "v${version}"; + tag = "v${version}"; hash = "sha256-60z6wbbXQp7MA5l7LP/mToZftX+nbcs2Mewg5jCFwFk="; }; @@ -26,6 +27,10 @@ buildGoModule rec { podman ]; + nativeCheckInputs = [ + writableTmpDirAsHomeHook + ]; + ldflags = [ "-s" "-w" @@ -46,8 +51,6 @@ buildGoModule rec { install -Dm444 README.md -t $out/share/docs/apx install -Dm444 COPYING.md $out/share/licenses/apx/LICENSE - # Create a temp writable home-dir so apx outputs completions without error - export HOME=$(mktemp -d) # apx command now works (for completions) # though complains "Error: no such file or directory" installShellCompletion --cmd apx \ @@ -56,12 +59,12 @@ buildGoModule rec { --zsh <($out/bin/apx completion zsh) ''; - meta = with lib; { + meta = { description = "Vanilla OS package manager"; homepage = "https://github.com/Vanilla-OS/apx"; changelog = "https://github.com/Vanilla-OS/apx/releases/tag/v${version}"; - license = licenses.gpl3Only; - maintainers = with maintainers; [ + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ dit7ya chewblacka ]; From a74cba712de4263f7897a3f5828ab89aa5e57b70 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 21:17:06 +0100 Subject: [PATCH 13/14] podman-tui: reformat + cleanup --- pkgs/by-name/po/podman-tui/package.nix | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/po/podman-tui/package.nix b/pkgs/by-name/po/podman-tui/package.nix index 08e5780f2e52..225d122ffa25 100644 --- a/pkgs/by-name/po/podman-tui/package.nix +++ b/pkgs/by-name/po/podman-tui/package.nix @@ -1,4 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, buildGoModule, testers, podman-tui }: +{ + lib, + stdenv, + fetchFromGitHub, + buildGoModule, + testers, + podman-tui, +}: buildGoModule rec { pname = "podman-tui"; @@ -15,15 +22,15 @@ buildGoModule rec { env.CGO_ENABLED = 0; - tags = [ "containers_image_openpgp" "remote" ] - ++ lib.optional stdenv.hostPlatform.isDarwin "darwin"; + tags = [ + "containers_image_openpgp" + "remote" + ] ++ lib.optional stdenv.hostPlatform.isDarwin "darwin"; - ldflags = [ "-s" "-w" ]; - - preCheck = '' - export USER="$(whoami)" - export HOME="$(mktemp -d)" - ''; + ldflags = [ + "-s" + "-w" + ]; checkFlags = let From 71cfe3bc7cd2b1f10b66d9aaa44459af561757cc Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jan 2025 21:51:25 +0100 Subject: [PATCH 14/14] python312Packages.accelerate: use `addBinToPathHook`, use `writableTmpDirAsHomeHook` --- .../python-modules/accelerate/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/development/python-modules/accelerate/default.nix b/pkgs/development/python-modules/accelerate/default.nix index ca17eda23dcb..6d8ff306900a 100644 --- a/pkgs/development/python-modules/accelerate/default.nix +++ b/pkgs/development/python-modules/accelerate/default.nix @@ -21,12 +21,14 @@ torch, # tests + addBinToPathHook, evaluate, parameterized, pytest7CheckHook, transformers, config, cudatoolkit, + writableTmpDirAsHomeHook, }: buildPythonPackage rec { @@ -56,19 +58,17 @@ buildPythonPackage rec { ]; nativeCheckInputs = [ + addBinToPathHook evaluate parameterized pytest7CheckHook transformers + writableTmpDirAsHomeHook ]; - preCheck = - '' - export HOME=$(mktemp -d) - export PATH=$out/bin:$PATH - '' - + lib.optionalString config.cudaSupport '' - export TRITON_PTXAS_PATH="${cudatoolkit}/bin/ptxas" - ''; + + preCheck = lib.optionalString config.cudaSupport '' + export TRITON_PTXAS_PATH="${cudatoolkit}/bin/ptxas" + ''; pytestFlagsArray = [ "tests" ]; disabledTests = [