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 308c2706fd059..375a544dc6a48 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 diff --git a/pkgs/by-name/am/amp/package.nix b/pkgs/by-name/am/amp/package.nix index 2d0890b63d67d..cd1e8eb7ca32c 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"; diff --git a/pkgs/by-name/ap/apx/package.nix b/pkgs/by-name/ap/apx/package.nix index b60e70a45c51c..5b9d3be524db3 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 ]; diff --git a/pkgs/by-name/aw/aws-shell/package.nix b/pkgs/by-name/aw/aws-shell/package.nix index 5b1222f5ef848..ed7646e6446c7 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"; diff --git a/pkgs/by-name/aw/awscli2/package.nix b/pkgs/by-name/aw/awscli2/package.nix index aa3a114c9d320..6eace0a32db7c 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 = '' diff --git a/pkgs/by-name/ha/hatch/package.nix b/pkgs/by-name/ha/hatch/package.nix index 5a5aff9e04739..215d6a45f1d0d 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 diff --git a/pkgs/by-name/he/hedgedoc/package.nix b/pkgs/by-name/he/hedgedoc/package.nix index 01b4b38e9b8dd..d22920bd0175b 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" ]' diff --git a/pkgs/by-name/me/meli/package.nix b/pkgs/by-name/me/meli/package.nix index 7640e4813d6c3..a9f17fa671831 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 ]; diff --git a/pkgs/by-name/me/menulibre/package.nix b/pkgs/by-name/me/menulibre/package.nix index 530d0f8f7ab6c..a5a9e2e8bb872 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 { diff --git a/pkgs/by-name/po/podman-tui/package.nix b/pkgs/by-name/po/podman-tui/package.nix index 08e5780f2e527..225d122ffa25f 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 diff --git a/pkgs/by-name/py/pylyzer/package.nix b/pkgs/by-name/py/pylyzer/package.nix index f413e1c583b8d..2d877f671de67 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 diff --git a/pkgs/by-name/sh/shopware-cli/package.nix b/pkgs/by-name/sh/shopware-cli/package.nix index fac9a4e22a0ae..16a8458e70866 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) \ diff --git a/pkgs/by-name/sn/snapcraft/package.nix b/pkgs/by-name/sn/snapcraft/package.nix index c7927f854cdf4..02c86328e71bc 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 = [ diff --git a/pkgs/development/python-modules/accelerate/default.nix b/pkgs/development/python-modules/accelerate/default.nix index ca17eda23dcbb..6d8ff306900aa 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 = [