From 4ad20b153f9c06df742b9e96f629aee4f45ede02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Thu, 7 Nov 2019 10:10:36 +0100 Subject: [PATCH 1/3] Fix Catalina --- .github/workflows/test.yml | 4 ++-- lib/main.js | 4 ++++ src/main.ts | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc6ecbc..f3d3e3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: tests: strategy: matrix: - os: [ubuntu-18.04, macos] + os: [ubuntu-18.04, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v1 @@ -17,4 +17,4 @@ jobs: - run: yarn test - name: Install Nix uses: ./ - - run: nix-build test.nix \ No newline at end of file + - run: nix-build test.nix diff --git a/lib/main.js b/lib/main.js index 97ae998..a4183df 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,6 +33,10 @@ function run() { yield exec.exec("sudo", ["sh", "-c", "echo http2 = false >> /etc/nix/nix.conf"]); // Set jobs to number of cores yield exec.exec("sudo", ["sh", "-c", "echo max-jobs = auto >> /etc/nix/nix.conf"]); + // Catalina workaround https://github.com/NixOS/nix/issues/2925 + if (os_1.type() == "Darwin") { + yield exec.exec("sudo", ["mount", "-uw", "/"]); + } // TODO: retry due to all the things that go wrong const nixInstall = yield tc.downloadTool('https://nixos.org/nix/install'); yield exec.exec("sh", [nixInstall]); diff --git a/src/main.ts b/src/main.ts index 2ed508a..195dc6a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; import * as tc from '@actions/tool-cache'; -import {homedir, userInfo} from 'os'; +import {homedir, userInfo, type} from 'os'; import {existsSync} from 'fs'; async function run() { @@ -18,6 +18,11 @@ async function run() { // Set jobs to number of cores await exec.exec("sudo", ["sh", "-c", "echo max-jobs = auto >> /etc/nix/nix.conf"]); + // Catalina workaround https://github.com/NixOS/nix/issues/2925 + if (type() == "Darwin") { + await exec.exec("sudo", ["mount", "-uw", "/"]); + } + // TODO: retry due to all the things that go wrong const nixInstall = await tc.downloadTool('https://nixos.org/nix/install'); await exec.exec("sh", [nixInstall]); From 9c08345130eb4dd10d8df48848d36b5a81655446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Thu, 7 Nov 2019 10:19:07 +0100 Subject: [PATCH 2/3] add shell.nix for easier development --- shell.nix | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..07f0cae --- /dev/null +++ b/shell.nix @@ -0,0 +1,8 @@ +{ pkgs ? import {} +}: + +pkgs.mkShell { + name = "install-nix-action-shell"; + + buildInputs = [ pkgs.yarn ]; +} From 9130accbad30d69fcfbbe9c990c90fb3f61f9a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Sun, 10 Nov 2019 19:22:39 +0100 Subject: [PATCH 3/3] try out catalina fix --- lib/main.js | 6 +++++- src/main.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index a4183df..c79b8f9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,6 +27,7 @@ function run() { const home = os_1.homedir(); const { username } = os_1.userInfo(); const PATH = process.env.PATH; + const INSTALL_PATH = '/opt/nix'; const CERTS_PATH = home + '/.nix-profile/etc/ssl/certs/ca-bundle.crt'; // Workaround a segfault: https://github.com/NixOS/nix/issues/2733 yield exec.exec("sudo", ["mkdir", "-p", "/etc/nix"]); @@ -35,7 +36,10 @@ function run() { yield exec.exec("sudo", ["sh", "-c", "echo max-jobs = auto >> /etc/nix/nix.conf"]); // Catalina workaround https://github.com/NixOS/nix/issues/2925 if (os_1.type() == "Darwin") { - yield exec.exec("sudo", ["mount", "-uw", "/"]); + 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"]); + core.exportVariable('NIX_IGNORE_SYMLINK_STORE', "1"); } // TODO: retry due to all the things that go wrong const nixInstall = yield tc.downloadTool('https://nixos.org/nix/install'); diff --git a/src/main.ts b/src/main.ts index 195dc6a..039c72f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,7 @@ async function run() { const home = homedir(); const {username} = userInfo(); const PATH = process.env.PATH; + const INSTALL_PATH = '/opt/nix'; const CERTS_PATH = home + '/.nix-profile/etc/ssl/certs/ca-bundle.crt'; // Workaround a segfault: https://github.com/NixOS/nix/issues/2733 @@ -20,7 +21,10 @@ async function run() { // Catalina workaround https://github.com/NixOS/nix/issues/2925 if (type() == "Darwin") { - await exec.exec("sudo", ["mount", "-uw", "/"]); + await exec.exec("sudo", ["sh", "-c", `echo \"nix\t${INSTALL_PATH}\" >> /etc/synthetic.conf`]); + await exec.exec("sudo", ["sh", "-c", `mkdir -m 0755 ${INSTALL_PATH} && chown runner ${INSTALL_PATH}`]); + await exec.exec("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util", ["-B"]); + core.exportVariable('NIX_IGNORE_SYMLINK_STORE', "1"); } // TODO: retry due to all the things that go wrong