Skip to content

Commit

Permalink
Make the post-build-hook use the daemon Nix package
Browse files Browse the repository at this point in the history
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).

(cherry picked from commit 93eadd5)
  • Loading branch information
thufschmitt authored and Ericson2314 committed Nov 30, 2021
1 parent 38e5b4a commit 75902c0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export PATH=@bindir@:$PATH
if [[ -n "${NIX_CLIENT_PACKAGE:-}" ]]; then
export PATH="$NIX_CLIENT_PACKAGE/bin":$PATH
fi
DAEMON_PATH="$PATH"
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
export NIX_DAEMON_COMMAND="$NIX_DAEMON_PACKAGE/bin/nix-daemon"
DAEMON_PATH="${NIX_DAEMON_PACKAGE}:$DAEMON_PATH"
fi
coreutils=@coreutils@

Expand Down Expand Up @@ -87,7 +88,7 @@ startDaemon() {
# Start the daemon, wait for the socket to appear. !!!
# ‘nix-daemon’ should have an option to fork into the background.
rm -f $NIX_DAEMON_SOCKET_PATH
${NIX_DAEMON_COMMAND:-nix-daemon} &
PATH=$DAEMON_PATH nix-daemon &
for ((i = 0; i < 30; i++)); do
if [[ -S $NIX_DAEMON_SOCKET_PATH ]]; then break; fi
sleep 1
Expand Down

0 comments on commit 75902c0

Please sign in to comment.