1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-18 02:58:27 +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:
John Ericson 2021-12-09 15:16:18 +00:00
parent 5dbbf23332
commit 87da941348
6 changed files with 44 additions and 27 deletions

View file

@ -129,9 +129,9 @@ endif
install-tests += $(foreach x, $(nix_tests), tests/$(x))
clean-files += $(d)/common.sh $(d)/config.nix $(d)/ca/config.nix
clean-files += $(d)/tests/common/vars-and-functions.sh $(d)/config.nix $(d)/ca/config.nix
test-deps += tests/common.sh tests/config.nix tests/ca/config.nix
test-deps += tests/common/vars-and-functions.sh tests/config.nix tests/ca/config.nix tests/plugins/libplugintest.$(SO_EXT)
ifeq ($(BUILD_SHARED_LIBS), 1)
test-deps += tests/plugins/libplugintest.$(SO_EXT)