diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a60b42..543d0b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,5 +19,6 @@ jobs: uses: ./ - run: nix-build test.nix - run: nix-env -iA cachix -f https://github.com/NixOS/nixpkgs/tarball/ab5863afada3c1b50fc43bf774b75ea71b287cde - # cachix should be available - - run: which cachix \ No newline at end of file + - run: cat /etc/nix/nix.conf + # cachix should be available and be able to configure a cache + - run: cachix use cachix \ No newline at end of file diff --git a/lib/main.js b/lib/main.js index 14d234a..9c9f33b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,6 +30,8 @@ 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"]); + // Allow binary caches for runner user + yield exec.exec("sudo", ["sh", "-c", "echo trusted-users = root runner >> /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`]); diff --git a/src/main.ts b/src/main.ts index 7df8ec2..119bd32 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,7 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; import * as tc from '@actions/tool-cache'; -import {homedir, userInfo, type} from 'os'; -import {existsSync} from 'fs'; +import {type} from 'os'; async function run() { try { @@ -16,6 +15,9 @@ async function run() { // Set jobs to number of cores await exec.exec("sudo", ["sh", "-c", "echo max-jobs = auto >> /etc/nix/nix.conf"]); + // Allow binary caches for runner user + await exec.exec("sudo", ["sh", "-c", "echo trusted-users = root runner >> /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`]);