Skip to content

Commit

Permalink
Merge pull request #9 from cachix/catalina
Browse files Browse the repository at this point in the history
Catalina
  • Loading branch information
domenkozar authored Nov 13, 2019
2 parents 65ed8d8 + 9130acc commit d140728
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,4 +17,4 @@ jobs:
- run: yarn test
- name: Install Nix
uses: ./
- run: nix-build test.nix
- run: nix-build test.nix
8 changes: 8 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ 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"]);
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", ["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');
yield exec.exec("sh", [nixInstall]);
Expand Down
8 changes: 8 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs ? import <nixpkgs> {}
}:

pkgs.mkShell {
name = "install-nix-action-shell";

buildInputs = [ pkgs.yarn ];
}
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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() {
try {
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
Expand All @@ -18,6 +19,14 @@ 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", ["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
const nixInstall = await tc.downloadTool('https://nixos.org/nix/install');
await exec.exec("sh", [nixInstall]);
Expand Down

0 comments on commit d140728

Please sign in to comment.