mirror of
https://github.com/cachix/install-nix-action.git
synced 2025-06-08 01:54:27 +00:00
macos: fix two issues
This commit is contained in:
parent
8b315ca141
commit
39c9ce7c86
3 changed files with 110 additions and 28 deletions
15
lib/main.js
15
lib/main.js
|
@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
const child_process_1 = require("child_process");
|
||||
const os_1 = require("os");
|
||||
function nixConf() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
@ -35,22 +36,14 @@ function run() {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const PATH = process.env.PATH;
|
||||
const INSTALL_PATH = '/opt/nix';
|
||||
yield nixConf();
|
||||
// Catalina workaround https://github.com/NixOS/nix/issues/2925
|
||||
if (os_1.type() == "Darwin") {
|
||||
yield exec.exec("sudo", ["sh", "-c", `echo \"nix\t${INSTALL_PATH}\" >> /etc/synthetic.conf`]);
|
||||
yield exec.exec("sudo", ["sh", "-c", `mkdir -m 0755 ${INSTALL_PATH} && chown runner ${INSTALL_PATH}`]);
|
||||
yield exec.exec("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util", ["-B"]);
|
||||
// Needed for sudo to pass NIX_IGNORE_SYMLINK_STORE
|
||||
yield exec.exec("sudo", ["sh", "-c", "echo 'Defaults env_keep += NIX_IGNORE_SYMLINK_STORE' >> /etc/sudoers"]);
|
||||
core.exportVariable('NIX_IGNORE_SYMLINK_STORE', "1");
|
||||
// Needed for nix-daemon installation
|
||||
yield exec.exec("sudo", ["launchctl", "setenv", "NIX_IGNORE_SYMLINK_STORE", "1"]);
|
||||
child_process_1.execFileSync(`${__dirname}/create-darwin-volume.sh`, { stdio: 'inherit' });
|
||||
}
|
||||
// Needed due to multi-user being too defensive
|
||||
core.exportVariable('ALLOW_PREEXISTING_INSTALLATION', "1");
|
||||
// TODO: retry due to all the things that go wrong
|
||||
// TODO: retry due to all the things that can go wrong
|
||||
const nixInstall = yield tc.downloadTool('https://nixos.org/nix/install');
|
||||
yield exec.exec("sh", [nixInstall, "--daemon"]);
|
||||
// write nix.conf again as installation overwrites it, reload the daemon to pick up changes
|
||||
|
@ -63,8 +56,6 @@ function run() {
|
|||
// macOS needs certificates hints
|
||||
core.exportVariable('NIX_SSL_CERT_FILE', '/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt');
|
||||
// TODO: nc doesn't work correctly on macOS :(
|
||||
//await exec.exec("sh", ["-c", "while ! nc -zU /nix/var/nix/daemon-socket/socket; do sleep 0.5; done"]);
|
||||
// macOS needs time to reload the daemon :(
|
||||
yield exec.exec("sleep", ["10"]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue