Skip to content

Commit

Permalink
modules/nix: Fix nix-daemon reload to not be racy
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinmit committed May 18, 2023
1 parent 9213b6c commit 9f7b510
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,11 @@ in
system.activationScripts.nix-daemon.text = mkIf cfg.useDaemon ''
if ! diff /etc/nix/nix.conf /run/current-system/etc/nix/nix.conf &> /dev/null; then
echo "reloading nix-daemon..." >&2
pid=$(launchctl kickstart -p system/org.nixos.nix-daemon)
launchctl kill HUP system/org.nixos.nix-daemon
while [ "$(launchctl kickstart -p system/org.nixos.nix-daemon)" = "$pid" ]; do
sleep 0.1
done
fi
while ! nix-store --store daemon -q --hash ${pkgs.stdenv.shell} &>/dev/null; do
echo "waiting for nix-daemon" >&2
Expand Down

0 comments on commit 9f7b510

Please sign in to comment.