Compare commits

..

96 Commits

Author SHA1 Message Date
20d5bae58c test installer options 2021-02-21 15:41:47 +00:00
0598b739d8 Merge pull request #68 from cachix/installer_options
be able to pass installer options
2021-02-21 13:41:03 +00:00
2e56a105a6 be able to pass installer options 2021-02-21 13:18:52 +00:00
3349b09732 README: bump flakes installer 2020-12-23 11:06:01 +01:00
b516682d84 Merge pull request #65 from zimbatm/shellcheck
fix shellcheck warnings
2020-12-22 21:17:33 +00:00
2e278dead1 fix shellcheck warnings
It's unlikely that those env vars will contain whitespaces, but it's
good to keep the script clean.
2020-12-22 20:11:31 +01:00
e6685eaf1d Merge pull request #57 from cachix/flakes-fix
Fix flakes example and add a test
2020-12-22 10:53:55 +00:00
0383d0d550 Fix flakes example and add a test 2020-12-22 11:45:56 +01:00
96aea9869b Merge pull request #64 from cachix/dependabot/npm_and_yarn/ini-1.3.8
Bump ini from 1.3.5 to 1.3.8
2020-12-12 09:30:00 +01:00
f43909d7a0 Bump ini from 1.3.5 to 1.3.8
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-11 22:00:42 +00:00
54ce86db4c Merge pull request #62 from Mic92/flakes
README: upgrade flake example
2020-12-03 15:24:36 +01:00
fa64b9ec04 README: upgrade flake example
tested with https://github.com/Mic92/dotfiles/runs/1491667409?check_suite_focus=true
2020-12-03 10:36:09 +01:00
ef4324316b README: clarify how to install packages via nix-env 2020-11-20 14:22:16 +01:00
68043fd3c3 README: clarify on how to run NixOS tests 2020-11-12 17:45:56 +01:00
575d5faa90 README: bump actions 2020-11-05 18:11:19 +01:00
07da2520ee README: move cachix integration to be more visible 2020-11-04 12:13:56 +01:00
661bbdf5ce Merge pull request #55 from numtide/idempotent
idempotent installation
2020-11-02 19:47:38 +01:00
334bb6100b idempotent installation
Don't run the installer if Nix has already been installed on the host.
We assume that the installed Nix is already in the desired state.

This allows to share a given pipeline between hosted and self-hosted
runners. Usually the self-hosted runners are long-lived and already have
Nix installed.
2020-11-02 12:35:41 +01:00
d5ba40b697 Merge pull request #53 from bbarker/patch-1
Adding more useful pinning reference to readme
2020-10-13 18:27:22 +02:00
fda16d28d8 Adding more useful pinning reference to readme 2020-10-13 11:26:47 -04:00
da678383b2 Merge pull request #52 from wamserma/patch-1
replace deprecated functions
2020-10-13 11:52:23 +02:00
8a37740405 replace deprecated functions
this should fix #50
2020-10-12 23:04:59 +02:00
28b1d88f39 Merge pull request #49 from cachix/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.1.1 to 1.2.6
2020-10-02 00:42:40 +03:00
2767b618db Bump @actions/core from 1.1.1 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.1 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:21:05 +00:00
aee3ec7ef5 README: mention why install_url is useful 2020-09-21 18:54:24 +02:00
ba5c343622 CI: trigger push only on master 2020-09-21 16:41:22 +02:00
8389c1826a Update README.md 2020-09-21 16:25:56 +02:00
95a8068e31 README: v11 2020-09-21 15:16:33 +02:00
9e0a5291c3 Fix #35: document nixpkgs version printing 2020-09-21 15:12:38 +02:00
b093d8fdd9 Document #19 2020-09-21 15:10:35 +02:00
6b9133ebb9 README: typo 2020-09-21 15:00:53 +02:00
05229ec560 README: update 2020-09-21 15:00:28 +02:00
97465807a1 Merge pull request #47 from cachix/prepare-v10
Support self-hosted runners and always skip adding a channel
2020-09-21 14:58:38 +02:00
cf5982c65c README: note on channels 2020-09-21 14:38:02 +02:00
4977bdad66 Update lib/install-nix.sh
Co-authored-by: zimbatm <zimbatm@zimbatm.com>
2020-09-21 14:30:19 +02:00
775aed5fcb Support self-hosted runners and always skip adding a channel 2020-09-21 14:16:30 +02:00
5a2cbacfff Merge pull request #46 from cachix/dependabot/npm_and_yarn/handlebars-4.7.6
Bump handlebars from 4.4.0 to 4.7.6
2020-09-07 16:59:47 +02:00
4bdb5ea92c Bump handlebars from 4.4.0 to 4.7.6
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.4.0 to 4.7.6.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.4.0...v4.7.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-07 12:01:35 +00:00
9dc00124fc Merge pull request #45 from zimbatm/extra-nix-config
add extra_nix_config options
2020-08-25 19:05:12 +02:00
967d234ad8 -n => != "" 2020-08-25 18:56:36 +02:00
07dda1e608 more cleanup 2020-08-25 18:26:01 +02:00
434ba1c7f0 fix the test 2020-08-25 18:20:10 +02:00
d953a4ee09 add failing test 2020-08-25 18:17:09 +02:00
dad23f2092 add extra_nix_config options
This also cleans the install-nix.sh script a bit
2020-08-25 18:08:00 +02:00
3559d01d05 Merge pull request #38 from cachix/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-19 07:09:50 +02:00
62a0c05281 Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-18 10:39:57 +00:00
9000f28930 Merge pull request #37 from cprussin/add-retries
Add retries when fetching nix install script
2020-07-09 13:35:55 +02:00
80dbe69d87 Add retries when fetching nix install script 2020-07-08 15:13:47 -07:00
1664fea144 add dependabot 2020-07-07 11:21:11 +02:00
41dfa36aa3 Update README.md 2020-06-03 17:18:31 +02:00
63cf434de4 remove unused file 2020-06-02 15:57:08 +02:00
2ebff14e68 Merge pull request #18 from Gerschtli/add-nixpkgs
Add NIX_PATH action input
2020-05-28 17:00:14 +02:00
a744770f4b Add nix_path action paramter 2020-05-28 16:28:14 +02:00
14f0e86ffb README: v9 2020-05-27 16:59:17 +02:00
4cbb444a96 Merge pull request #33 from cachix/nix-2.3.5
Nix 2.3.5
2020-05-27 16:44:25 +02:00
f68249e909 Nix 2.3.5 2020-05-27 16:39:05 +02:00
10a7d51bce allow skipping channel installation 2020-05-27 13:22:53 +02:00
642cfa0200 Prepare for Nix 2.3.5 2020-05-26 18:08:30 +02:00
d3c3fef7d5 Merge pull request #32 from cachix/install_url
Allow overriding installation URL
2020-05-26 14:31:35 +02:00
1c67340d91 Merge pull request #31 from cachix/improve-ci
improve CI
2020-05-26 10:06:49 +02:00
afb82faed7 Allow overriding installation URL 2020-05-14 13:21:40 +02:00
bc19d99f45 improve CI 2020-05-12 12:57:56 +02:00
5ab66ea04b README: bump version 2020-04-22 16:42:26 +02:00
1b7507cdbf Merge pull request #30 from cachix/dependabot/npm_and_yarn/acorn-5.7.4
Bump acorn from 5.7.3 to 5.7.4
2020-04-10 13:12:43 +02:00
5bba53f2a2 Bump acorn from 5.7.3 to 5.7.4
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-04-05 06:26:25 +00:00
ebed63b0a2 Allow installation path to redirect 2020-03-11 19:29:13 +01:00
5c21a08208 README: bump actions 2020-03-01 11:47:40 +01:00
9affe1ce81 Merge pull request #27 from cachix/revert-26-sandbox
Revert "Enable sandbox on darwin"
2020-02-26 19:23:19 +03:00
ef735e86b9 Revert "Enable sandbox on darwin" 2020-02-26 17:17:21 +01:00
4856b67e4a Merge pull request #26 from cachix/sandbox
Enable sandbox on darwin
2020-02-26 17:12:40 +03:00
6e3de2b50b Enable sandbox on darwin 2020-02-26 14:53:51 +01:00
d8ecc134bc Merge pull request #25 from cachix/rewrite-bash
rewrite to bash
2020-02-26 16:44:17 +03:00
dba72516a1 rewrite to bash 2020-02-26 14:23:08 +01:00
df989ac1d6 Merge pull request #24 from cachix/macos-spotlight
macos: disable spotlight
2020-02-26 13:43:37 +03:00
a5f8eada85 macos: disable spotlight 2020-02-26 11:21:33 +01:00
f57eb6b95e Merge pull request #23 from cachix/macos
MacOS fixes
2020-02-26 13:06:39 +03:00
033d472283 darwin: reliably wait for daemon connection 2020-02-24 13:20:47 +01:00
39c9ce7c86 macos: fix two issues 2020-02-24 10:09:32 +01:00
8b315ca141 bump 2019-11-20 15:39:17 +01:00
cd5893b2c6 Merge pull request #14 from cachix/multi-user-fixes
Multi user fixes
2019-11-19 17:47:10 +01:00
c9b9c77f3b wait for nix-daemon socket 2019-11-19 14:08:06 +01:00
16107722cd re-setup nix.conf after installation 2019-11-19 12:48:58 +01:00
9420096b1d allow binary caches for runner user 2019-11-19 12:48:58 +01:00
15adaed2d7 expose nix executables also for runner user 2019-11-19 12:48:58 +01:00
addc7fa7a2 Merge pull request #12 from cachix/sandbox
Turn on daemon (multi-user) mode
2019-11-19 11:29:33 +01:00
b8c38b583f Turn on daemon (multi-user) mode 2019-11-19 11:22:13 +01:00
d1407282e6 Merge pull request #9 from cachix/catalina
Catalina
2019-11-13 16:52:08 +01:00
9130accbad try out catalina fix 2019-11-13 16:47:37 +01:00
9c08345130 add shell.nix for easier development 2019-11-07 10:19:07 +01:00
4ad20b153f Fix Catalina 2019-11-07 10:18:56 +01:00
65ed8d8b59 README: bump 2019-10-03 17:40:55 +02:00
e3eb20c3db README: hint to action options 2019-10-03 17:27:13 +02:00
2b219c86f3 Merge pull request #8 from cachix/5-max-jobs
fix #5: set max-jobs = auto
2019-10-03 17:26:22 +02:00
ba979b5e7d fix #5: set max-jobs = auto 2019-10-03 17:23:24 +02:00
67bd092214 bump 2019-10-02 17:38:16 +02:00
f104d5a8aa Merge pull request #4 from cachix/fix-build-check
test that build produces no diff
2019-10-02 16:49:24 +02:00
12 changed files with 291 additions and 158 deletions

13
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: '00:00'
timezone: UTC
open-pull-requests-limit: 10
commit-message:
prefix: "chore"
include: "scope"

View File

@ -2,19 +2,96 @@ name: "install-nix-action test"
on: on:
pull_request: pull_request:
push: push:
branches:
- master
jobs: jobs:
tests: simple-build:
strategy: strategy:
matrix: matrix:
os: [ubuntu-18.04, macos] os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn build - run: yarn build
# TODO: just commit it using github
- run: git diff --exit-code
- run: yarn test
- name: Install Nix - name: Install Nix
uses: ./ uses: ./
- run: nix-build test.nix with:
nix_path: nixpkgs=channel:nixos-20.03
- run: nix-env -iA cachix -f https://cachix.org/api/v1/install
- run: cat /etc/nix/nix.conf
# cachix should be available and be able to configure a cache
- run: cachix use cachix
- run: nix-build test.nix
custom-nix-path:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
uses: ./
with:
nix_path: nixpkgs=channel:nixos-20.03
- run: test $NIX_PATH == "nixpkgs=channel:nixos-20.03"
- run: nix-build test.nix
extra-nix-config:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
uses: ./
with:
nix_path: nixpkgs=channel:nixos-20.03
extra_nix_config: |
sandbox = relaxed
- run: cat /etc/nix/nix.conf
- run: nix-build test.nix --arg noChroot true
flakes:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
uses: ./
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix flake show github:NixOS/nixpkgs
installer-options:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
uses: ./
with:
nix_path: nixpkgs=channel:nixos-20.03
install_url: https://nix-ci.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
install_options: '--tarball-url-prefix https://nix-ci.cachix.org/serve'
- run: nix-build test.nix

View File

@ -4,6 +4,21 @@
Installs [Nix](https://nixos.org/nix/) on GitHub Actions for the supported platforms: Linux and macOS. Installs [Nix](https://nixos.org/nix/) on GitHub Actions for the supported platforms: Linux and macOS.
By default it has no nixpkgs configured, you have to set `nix_path`
by [picking a channel](https://status.nixos.org/)
or [pin nixpkgs yourself](https://nix.dev/reference/pinning-nixpkgs.html)
(see also [pinning tutorial](https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html)).
# Features
- Quick installation (~4s on Linux, ~20s on macOS)
- Multi-User installation (with sandboxing enabled only on Linux)
- [Self-hosted github runner](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) support
- Allows specifying Nix installation URL via `install_url`
- Allows specifying extra Nix configration options via `extra_nix_config`
- Allows specifying `$NIX_PATH` and channels via `nix_path`
- Share `/nix/store` between builds using [cachix-action](https://github.com/cachix/cachix-action) for simple binary cache setup to speed up your builds and share binaries with your team
## Usage ## Usage
Create `.github/workflows/test.yml` in your repo with the following contents: Create `.github/workflows/test.yml` in your repo with the following contents:
@ -17,17 +32,76 @@ jobs:
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v1 - uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix-build - run: nix-build
``` ```
See also [cachix-action](https://github.com/cachix/cachix-action) for
simple binary cache setup to speed up your builds and share binaries ## Usage with Flakes
with developers.
```yaml
name: "Test"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v12
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix-build
```
## Inputs (specify using `with:`)
- `install_url`: specify URL to install Nix from (useful for testing non-stable releases or pinning Nix for example https://releases.nixos.org/nix/nix-2.3.7/install)
- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable`
- `extra_nix_config`: append to `/etc/nix/nix.conf`
--- ---
## FAQ
### Is it possible to run NixOS tests / Qemu+KVM with GitHub Actions?
[Currently GitHub Actions are not running on Azure instance types that support nested virtualization](https://github.com/actions/virtual-environments/issues/183#issuecomment-610723516).
### How do I print nixpkgs version I have configured?
```nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'```
### How can I run NixOS tests?
With the following inputs:
```yaml
- uses: cachix/install-nix-action@vXX
with:
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm"
```
Note that there's no hardware acceleration on GitHub Actions.
### How can I install packages via nix-env from the specified `nix_path`?
```
nix-env -i mypackage -f '<nixpkgs>'
```
## Hacking ## Hacking
Install the dependencies Install the dependencies

View File

@ -1,6 +1,15 @@
name: 'Install Nix' name: 'Install Nix'
description: 'Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.' description: 'Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.'
author: 'Domen Kožar' author: 'Domen Kožar'
inputs:
install_url:
description: 'Installation URL that will contain a script to install Nix.'
install_options:
description: 'Additional installer flags passed to the installer script.'
nix_path:
description: 'Set NIX_PATH environment variable.'
extra_nix_config:
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
branding: branding:
color: 'blue' color: 'blue'
icon: 'sun' icon: 'sun'

59
lib/install-nix.sh Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail
if type -p nix &>/dev/null ; then
echo "Aborting: Nix is already installed at $(type -p nix)"
exit
fi
# Configure Nix
add_config() {
echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null
}
# Set jobs to number of cores
add_config "max-jobs = auto"
# Allow binary caches for user
add_config "trusted-users = root $USER"
# Append extra nix configuration if provided
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
add_config "$INPUT_EXTRA_NIX_CONFIG"
fi
# Nix installer flags
installer_options=(
--daemon
--daemon-user-count 4
--no-channel-add
--darwin-use-unencrypted-nix-store-volume
--nix-extra-conf-file /tmp/nix.conf
)
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
IFS=' ' read -r -a extra_installer_options <<< $INPUT_INSTALL_OPTIONS
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
fi
echo "installer options: ${installer_options[@]}"
# On self-hosted runners we don't need to install more than once
if [[ ! -d /nix/store ]]
then
sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") "${installer_options[@]}"
fi
if [[ $OSTYPE =~ darwin ]]; then
# Disable spotlight indexing of /nix to speed up performance
sudo mdutil -i off /nix
# macOS needs certificates hints
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
echo "NIX_SSL_CERT_FILE=$cert_file" >> "$GITHUB_ENV"
export NIX_SSL_CERT_FILE=$cert_file
sudo launchctl setenv NIX_SSL_CERT_FILE "$cert_file"
fi
# Set paths
echo "/nix/var/nix/profiles/per-user/$USER/profile/bin" >> "$GITHUB_PATH"
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
if [[ $INPUT_NIX_PATH != "" ]]; then
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
fi

View File

@ -1,50 +1,4 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const child_process_1 = require("child_process");
const exec = __importStar(require("@actions/exec")); child_process_1.execFileSync(`${__dirname}/install-nix.sh`, { stdio: 'inherit' });
const tc = __importStar(require("@actions/tool-cache"));
const os_1 = require("os");
const fs_1 = require("fs");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const home = os_1.homedir();
const { username } = os_1.userInfo();
const PATH = process.env.PATH;
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", ["echo", "http2 = false", ">>", "/etc/nix/nix.conf"]);
// 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]);
core.exportVariable('PATH', `${PATH}:${home}/.nix-profile/bin`);
core.exportVariable('NIX_PATH', `/nix/var/nix/profiles/per-user/${username}/channels`);
// macOS needs certificates hints
if (fs_1.existsSync(CERTS_PATH)) {
core.exportVariable('NIX_SSL_CERT_FILE', CERTS_PATH);
}
}
catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw (error);
}
});
}
run();

View File

@ -1,8 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function extrasperse(elem, array) {
const init = [];
return array.reduce((r, a) => r.concat(elem, a), init);
}
exports.extrasperse = extrasperse;
;

View File

@ -20,7 +20,7 @@
"author": "Domen Kožar", "author": "Domen Kožar",
"license": "ASL2", "license": "ASL2",
"dependencies": { "dependencies": {
"@actions/core": "^1.1.0", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/tool-cache": "^1.1.2" "@actions/tool-cache": "^1.1.2"
}, },

8
shell.nix Normal file
View File

@ -0,0 +1,8 @@
{ pkgs ? import <nixpkgs> {}
}:
pkgs.mkShell {
name = "install-nix-action-shell";
buildInputs = [ pkgs.yarn ];
}

View File

@ -1,34 +1,3 @@
import * as core from '@actions/core'; import { execFileSync } from 'child_process';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import {homedir, userInfo} from 'os';
import {existsSync} from 'fs';
async function run() { execFileSync(`${__dirname}/install-nix.sh`, { stdio: 'inherit' });
try {
const home = homedir();
const {username} = userInfo();
const PATH = process.env.PATH;
const CERTS_PATH = home + '/.nix-profile/etc/ssl/certs/ca-bundle.crt';
// Workaround a segfault: https://github.com/NixOS/nix/issues/2733
await exec.exec("sudo", ["mkdir", "-p", "/etc/nix"]);
await exec.exec("sudo", ["echo", "http2 = false", ">>", "/etc/nix/nix.conf"]);
// 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]);
core.exportVariable('PATH', `${PATH}:${home}/.nix-profile/bin`)
core.exportVariable('NIX_PATH', `/nix/var/nix/profiles/per-user/${username}/channels`)
// macOS needs certificates hints
if (existsSync(CERTS_PATH)) {
core.exportVariable('NIX_SSL_CERT_FILE', CERTS_PATH);
}
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw(error);
}
}
run();

View File

@ -2,14 +2,17 @@
{ size ? 1 # MB { size ? 1 # MB
, num ? 10 # count , num ? 10 # count
, currentTime ? builtins.currentTime , currentTime ? builtins.currentTime
, noChroot ? false
}: }:
with import <nixpkgs> {}; with import <nixpkgs> {};
let let
drv = i: runCommand "${toString currentTime}-${toString i}" {} '' drv = i: runCommand "${toString currentTime}-${toString i}" {
__noChroot = noChroot;
} ''
dd if=/dev/zero of=$out bs=${toString size}MB count=1 dd if=/dev/zero of=$out bs=${toString size}MB count=1
''; '';
in writeText "empty-${toString num}-${toString size}MB" '' in writeText "empty-${toString num}-${toString size}MB" ''
${lib.concatMapStringsSep "" drv (lib.range 1 num)} ${lib.concatMapStringsSep "" drv (lib.range 1 num)}
'' ''

View File

@ -2,10 +2,10 @@
# yarn lockfile v1 # yarn lockfile v1
"@actions/core@^1.1.0": "@actions/core@^1.1.0", "@actions/core@^1.2.6":
version "1.1.1" version "1.2.6"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.1.1.tgz#e08f3dbfe04721bb3d040f8fca2d6d7e1817b2e1" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
integrity sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg== integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
"@actions/exec@^1.0.1": "@actions/exec@^1.0.1":
version "1.0.1" version "1.0.1"
@ -424,9 +424,9 @@ acorn-walk@^6.0.1:
integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA== integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==
acorn@^5.5.3: acorn@^5.5.3:
version "5.7.3" version "5.7.4"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw== integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==
acorn@^6.0.1: acorn@^6.0.1:
version "6.3.0" version "6.3.0"
@ -803,11 +803,6 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies: dependencies:
delayed-stream "~1.0.0" delayed-stream "~1.0.0"
commander@~2.20.0:
version "2.20.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.1.tgz#3863ce3ca92d0831dcf2a102f5fb4b5926afd0f9"
integrity sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==
component-emitter@^1.2.1: component-emitter@^1.2.1:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
@ -1318,13 +1313,14 @@ growly@^1.3.0:
integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=
handlebars@^4.1.2: handlebars@^4.1.2:
version "4.4.0" version "4.7.6"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.4.0.tgz#22e1a897c5d83023d39801f35f6b65cf97ed8b25" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
integrity sha512-xkRtOt3/3DzTKMOt3xahj2M/EqNhY988T+imYSlMgs5fVhLN2fmKVVj0LtEGmb+3UUYV5Qmm1052Mm3dIQxOvw== integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
dependencies: dependencies:
minimist "^1.2.5"
neo-async "^2.6.0" neo-async "^2.6.0"
optimist "^0.6.1"
source-map "^0.6.1" source-map "^0.6.1"
wordwrap "^1.0.0"
optionalDependencies: optionalDependencies:
uglify-js "^3.1.4" uglify-js "^3.1.4"
@ -1456,9 +1452,9 @@ inherits@2, inherits@~2.0.3:
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
ini@~1.3.0: ini@~1.3.0:
version "1.3.5" version "1.3.8"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==
invariant@^2.2.4: invariant@^2.2.4:
version "2.2.4" version "2.2.4"
@ -2225,9 +2221,9 @@ lodash.sortby@^4.7.0:
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash@^4.17.11, lodash@^4.17.13: lodash@^4.17.11, lodash@^4.17.13:
version "4.17.15" version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
loose-envify@^1.0.0: loose-envify@^1.0.0:
version "1.4.0" version "1.4.0"
@ -2316,15 +2312,10 @@ minimist@0.0.8:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
minimist@^1.1.1, minimist@^1.2.0: minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
version "1.2.0" version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=
minipass@^2.6.0, minipass@^2.8.6: minipass@^2.6.0, minipass@^2.8.6:
version "2.8.6" version "2.8.6"
@ -2411,9 +2402,9 @@ needle@^2.2.1:
sax "^1.2.4" sax "^1.2.4"
neo-async@^2.6.0: neo-async@^2.6.0:
version "2.6.1" version "2.6.2"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==
nice-try@^1.0.4: nice-try@^1.0.4:
version "1.0.5" version "1.0.5"
@ -2580,14 +2571,6 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0:
dependencies: dependencies:
wrappy "1" wrappy "1"
optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
integrity sha1-2j6nRob6IaGaERwybpDrFaAZZoY=
dependencies:
minimist "~0.0.1"
wordwrap "~0.0.2"
optionator@^0.8.1: optionator@^0.8.1:
version "0.8.2" version "0.8.2"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
@ -3459,12 +3442,9 @@ typescript@^3.5.1:
integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw== integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==
uglify-js@^3.1.4: uglify-js@^3.1.4:
version "3.6.0" version "3.10.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.4.tgz#dd680f5687bc0d7a93b14a3482d16db6eba2bfbb"
integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg== integrity sha512-kBFT3U4Dcj4/pJ52vfjCSfyLyvG9VYYuGYPmrPvAxRw/i7xHiT4VvCev+uiEMcEEiu6UNB6KgWmGtSUYIWScbw==
dependencies:
commander "~2.20.0"
source-map "~0.6.1"
underscore@1.8.3: underscore@1.8.3:
version "1.8.3" version "1.8.3"
@ -3609,12 +3589,7 @@ wide-align@^1.1.0:
dependencies: dependencies:
string-width "^1.0.2 || 2" string-width "^1.0.2 || 2"
wordwrap@~0.0.2: wordwrap@^1.0.0, wordwrap@~1.0.0:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc=
wordwrap@~1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=