mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
87da941348
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).
12 lines
245 B
Bash
12 lines
245 B
Bash
set -e
|
|
|
|
if [[ -z "${COMMON_SH_SOURCED-}" ]]; then
|
|
|
|
COMMON_SH_SOURCED=1
|
|
|
|
source "$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")/common/vars-and-functions.sh"
|
|
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
|
|
startDaemon
|
|
fi
|
|
|
|
fi # COMMON_SH_SOURCED
|