Allow Nix to be installed in single-user mode

(cherry picked from commit 476599180e7c5d616cb06a852a564bd56298e468)
Signed-off-by: Domen Kožar <domen@dev.si>
This commit is contained in:
Domen Kožar 2019-12-20 13:06:33 +01:00
commit 76bd1745d3
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
2 changed files with 8 additions and 4 deletions

View file

@ -61,13 +61,15 @@ function run() {
// enable post-build-hook // enable post-build-hook
yield exec.exec("sudo", ["sh", "-c", `echo post-build-hook = /etc/nix/cachix-push.sh >> /etc/nix/nix.conf`]); yield exec.exec("sudo", ["sh", "-c", `echo post-build-hook = /etc/nix/cachix-push.sh >> /etc/nix/nix.conf`]);
core.exportVariable('CACHIX_SIGNING_KEY', signingKey); core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
// Ignore reloading failures as Nix might be installed in single-user mode (install-nix-action version 5 or lower)
const options = { ignoreReturnCode: true };
// Reload nix-daemon // Reload nix-daemon
if (os_1.type() == "Darwin") { if (os_1.type() == "Darwin") {
// kickstart awaits nix-daemon to get up again // kickstart awaits nix-daemon to get up again
yield exec.exec("sudo", ["launchctl", "kickstart", "-k", "system/org.nixos.nix-daemon"]); yield exec.exec("sudo", ["launchctl", "kickstart", "-k", "system/org.nixos.nix-daemon"], options);
} }
else { else {
yield exec.exec("sudo", ["pkill", "-HUP", "nix-daemon"]); yield exec.exec("sudo", ["pkill", "-HUP", "nix-daemon"], options);
} }
core.endGroup(); core.endGroup();
} }

View file

@ -48,12 +48,14 @@ async function run() {
await exec.exec("sudo", ["sh", "-c", `echo post-build-hook = /etc/nix/cachix-push.sh >> /etc/nix/nix.conf`]); await exec.exec("sudo", ["sh", "-c", `echo post-build-hook = /etc/nix/cachix-push.sh >> /etc/nix/nix.conf`]);
core.exportVariable('CACHIX_SIGNING_KEY', signingKey); core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
// Ignore reloading failures as Nix might be installed in single-user mode (install-nix-action version 5 or lower)
const options = { ignoreReturnCode: true };
// Reload nix-daemon // Reload nix-daemon
if (type() == "Darwin") { if (type() == "Darwin") {
// kickstart awaits nix-daemon to get up again // kickstart awaits nix-daemon to get up again
await exec.exec("sudo", ["launchctl", "kickstart", "-k", "system/org.nixos.nix-daemon"]); await exec.exec("sudo", ["launchctl", "kickstart", "-k", "system/org.nixos.nix-daemon"], options);
} else { } else {
await exec.exec("sudo", ["pkill", "-HUP", "nix-daemon"]); await exec.exec("sudo", ["pkill", "-HUP", "nix-daemon"], options);
} }
core.endGroup(); core.endGroup();