Skip to content

Commit

Permalink
build-support: add writableTmpDirAsHomeHook hook
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jan 11, 2025
1 parent 3522886 commit 9e45c4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkgs/build-support/setup-hooks/writable-tmpdir-as-home.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# shellcheck shell=bash
# This setup hook set the HOME environment variable to a temporary directory.

export HOME

writableTmpDirAsHome () {
if [[ ! -w "$HOME" ]]; then
HOME=$(mktemp -d)
export HOME
fi
}

# shellcheck disable=SC2154
addEnvHooks "$targetOffset" writableTmpDirAsHome
7 changes: 7 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,13 @@ with pkgs;
name = "setup-debug-info-dirs-hook";
} ../build-support/setup-hooks/setup-debug-info-dirs.sh;

writableTmpDirAsHomeHook = callPackage (
{ makeSetupHook }:
makeSetupHook {
name = "writable-tmpdir-as-home-hook";
} ../build-support/setup-hooks/writable-tmpdir-as-home.sh
) { };

useOldCXXAbi = makeSetupHook {
name = "use-old-cxx-abi-hook";
} ../build-support/setup-hooks/use-old-cxx-abi.sh;
Expand Down

0 comments on commit 9e45c4c

Please sign in to comment.