mirror of
https://github.com/NixOS/nix
synced 2025-07-07 14:21:48 +02:00
Clean up daemon handling
Split `common.sh` into the vars and functions definitions vs starting the daemon (and possibly other initialization logic). This way, `init.sh` can just `source` the former. Trying to start the daemon before `nix.conf` is written will fail because `nix daemon` requires `--experimental-features 'nix-command'`. `killDaemon` is idempotent, so it's safe to call when no daemon is running. `startDaemon` and `killDaemon` use the PID (which is now exported to subshells) to decide whether there is work to be done, rather than `NIX_REMOTE`, which might conceivably be set differently even if a daemon is running. `startDaemon` and `killDaemon` can save/restore the old `NIX_REMOTE` as `NIX_REMOTE_OLD`. `init.sh` kills daemon before deleting everything (including the daemon socket).
This commit is contained in:
parent
5dbbf23332
commit
87da941348
6 changed files with 44 additions and 27 deletions
|
@ -1,14 +1,13 @@
|
|||
set -e -o pipefail
|
||||
set -eu -o pipefail
|
||||
|
||||
source common.sh
|
||||
# Don't start the daemon
|
||||
source common/vars-and-functions.sh
|
||||
|
||||
test -n "$TEST_ROOT"
|
||||
if test -d "$TEST_ROOT"; then
|
||||
chmod -R u+w "$TEST_ROOT"
|
||||
# We would delete any daemon socket, so let's stop the daemon first.
|
||||
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
|
||||
killDaemon
|
||||
fi
|
||||
killDaemon
|
||||
rm -rf "$TEST_ROOT"
|
||||
fi
|
||||
mkdir "$TEST_ROOT"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue