Only stop the nix daemon if it's actually active, not just enabled (#410)

* Only stop the nix daemon if it's actually active, not just enabled

* Add vm-tests
This commit is contained in:
Ana Hobden 2023-04-10 12:47:34 -07:00 committed by GitHub
parent 352a50b921
commit 16ddada7a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 6 deletions

View file

@ -236,6 +236,17 @@ let
uninstall = installCases.install-default.uninstall;
uninstallCheck = installCases.install-default.uninstallCheck;
};
cure-self-multi-broken-daemon-stopped = {
preinstall = ''
${nix-installer-install-quiet}
sudo mv /nix/receipt.json /nix/old-receipt.json
sudo systemctl stop nix-daemon.socket
'';
install = installCases.install-default.install;
check = installCases.install-default.check;
uninstall = installCases.install-default.uninstall;
uninstallCheck = installCases.install-default.uninstallCheck;
};
cure-self-linux-broken-no-etc-nix = {
preinstall = ''
${nix-installer-install-quiet}
@ -290,6 +301,16 @@ let
uninstall = installCases.install-default.uninstall;
uninstallCheck = installCases.install-default.uninstallCheck;
};
cure-script-multi-broken-daemon-stopped = {
preinstall = ''
${cure-script-multi-user}
sudo systemctl stop nix-daemon.socket
'';
install = installCases.install-default.install;
check = installCases.install-default.check;
uninstall = installCases.install-default.uninstall;
uninstallCheck = installCases.install-default.uninstallCheck;
};
cure-script-multi-broken-no-etc-nix = {
preinstall = ''
${cure-script-multi-user}

View file

@ -246,13 +246,13 @@ impl Action for ConfigureInitService {
.map_err(Self::error)?;
}
// The goal state is the `socket` enabled and active, the service not enabled and stopped (it activates via socket activation)
if is_enabled("nix-daemon.socket").await.map_err(Self::error)? {
disable("nix-daemon.socket", false)
.await
.map_err(Self::error)?;
}
let socket_was_active =
if is_enabled("nix-daemon.socket").await.map_err(Self::error)? {
disable("nix-daemon.socket", true)
.await
.map_err(Self::error)?;
true
} else if is_active("nix-daemon.socket").await.map_err(Self::error)? {
if is_active("nix-daemon.socket").await.map_err(Self::error)? {
stop("nix-daemon.socket").await.map_err(Self::error)?;
true
} else {