Skip to content

Commit 93eadd5

Browse files
committed
Make the post-build-hook use the daemon Nix package
Having the `post-build-hook` use `nix` from the client package can lead to a deadlock in case there’s a db migration to do between both, as a `nix` command running inside the hook will run as root (and as such will bypass the daemon), so might trigger a db migration, which will get stuck trying to get a global lock on the DB (as the daemon that ran the hook already has a lock on it).
1 parent 7d6017b commit 93eadd5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/common.sh.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export PATH=@bindir@:$PATH
3636
if [[ -n "${NIX_CLIENT_PACKAGE:-}" ]]; then
3737
export PATH="$NIX_CLIENT_PACKAGE/bin":$PATH
3838
fi
39+
DAEMON_PATH="$PATH"
3940
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
40-
export NIX_DAEMON_COMMAND="$NIX_DAEMON_PACKAGE/bin/nix-daemon"
41+
DAEMON_PATH="${NIX_DAEMON_PACKAGE}:$DAEMON_PATH"
4142
fi
4243
coreutils=@coreutils@
4344

@@ -89,7 +90,7 @@ startDaemon() {
8990
# Start the daemon, wait for the socket to appear. !!!
9091
# ‘nix-daemon’ should have an option to fork into the background.
9192
rm -f $NIX_DAEMON_SOCKET_PATH
92-
${NIX_DAEMON_COMMAND:-nix daemon} &
93+
PATH=$DAEMON_PATH nix daemon &
9394
for ((i = 0; i < 30; i++)); do
9495
if [[ -S $NIX_DAEMON_SOCKET_PATH ]]; then break; fi
9596
sleep 1

0 commit comments

Comments
 (0)