Compare commits

..

25 Commits

Author SHA1 Message Date
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
6 changed files with 74 additions and 24 deletions

View File

@ -2,6 +2,8 @@ name: "install-nix-action test"
on: on:
pull_request: pull_request:
push: push:
branches:
- master
jobs: jobs:
simple-build: simple-build:
@ -56,3 +58,23 @@ jobs:
sandbox = relaxed sandbox = relaxed
- run: cat /etc/nix/nix.conf - run: cat /etc/nix/nix.conf
- run: nix-build test.nix --arg noChroot true - 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

View File

@ -6,7 +6,8 @@ Installs [Nix](https://nixos.org/nix/) on GitHub Actions for the supported platf
By default it has no nixpkgs configured, you have to set `nix_path` By default it has no nixpkgs configured, you have to set `nix_path`
by [picking a channel](https://status.nixos.org/) by [picking a channel](https://status.nixos.org/)
or [pin nixpkgs yourself](https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html). 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 # Features
@ -16,6 +17,7 @@ or [pin nixpkgs yourself](https://nix.dev/tutorials/towards-reproducibility-pinn
- Allows specifying Nix installation URL via `install_url` - Allows specifying Nix installation URL via `install_url`
- Allows specifying extra Nix configration options via `extra_nix_config` - Allows specifying extra Nix configration options via `extra_nix_config`
- Allows specifying `$NIX_PATH` and channels via `nix_path` - 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
@ -30,20 +32,17 @@ jobs:
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v11 - uses: cachix/install-nix-action@v12
with: with:
nix_path: nixpkgs=channel:nixos-unstable 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
with developers.
## Usage with Flakes ## Usage with Flakes
``` ```yaml
name: "Test" name: "Test"
on: on:
pull_request: pull_request:
@ -56,9 +55,9 @@ jobs:
with: with:
# Nix Flakes doesn't work on shallow clones # Nix Flakes doesn't work on shallow clones
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v11 - uses: cachix/install-nix-action@v12
with: with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-3.0pre20200820_4d77513/install install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: | extra_nix_config: |
experimental-features = nix-command flakes experimental-features = nix-command flakes
- run: nix-build - run: nix-build
@ -66,7 +65,7 @@ jobs:
## Inputs (specify using `with:`) ## Inputs (specify using `with:`)
- `install_url`: specify URL to install Nix from (useful for testing non-stable releases) - `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` - `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable`
@ -80,11 +79,29 @@ jobs:
[Currently GitHub Actions are not running on Azure instance types that support nested virtualization](https://github.com/actions/virtual-environments/issues/183#issuecomment-610723516). [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 with the channel I have configured? ### How do I print nixpkgs version I have configured?
```nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'``` ```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

@ -3,7 +3,9 @@ description: 'Installs Nix on GitHub Actions for the supported platforms: Linux
author: 'Domen Kožar' author: 'Domen Kožar'
inputs: inputs:
install_url: install_url:
description: 'Installation URL that will contain a script to install Nix' description: 'Installation URL that will contain a script to install Nix.'
install_options:
description: 'Additional installer flags passed to the installer script.'
nix_path: nix_path:
description: 'Set NIX_PATH environment variable.' description: 'Set NIX_PATH environment variable.'
extra_nix_config: extra_nix_config:

View File

@ -1,6 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
if type -p nix &>/dev/null ; then
echo "Aborting: Nix is already installed at $(type -p nix)"
exit
fi
# Configure Nix # Configure Nix
add_config() { add_config() {
echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null
@ -22,7 +27,11 @@ installer_options=(
--darwin-use-unencrypted-nix-store-volume --darwin-use-unencrypted-nix-store-volume
--nix-extra-conf-file /tmp/nix.conf --nix-extra-conf-file /tmp/nix.conf
) )
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
installer_options=("${installer_options[@]}" "${INPUT_INSTALL_OPTIONS[@]}")
fi
echo "installer options: ${installer_options[@]}"
# On self-hosted runners we don't need to install more than once # On self-hosted runners we don't need to install more than once
if [[ ! -d /nix/store ]] if [[ ! -d /nix/store ]]
then then
@ -35,15 +44,15 @@ if [[ $OSTYPE =~ darwin ]]; then
# macOS needs certificates hints # macOS needs certificates hints
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
echo "::set-env name=NIX_SSL_CERT_FILE::$cert_file" echo "NIX_SSL_CERT_FILE=$cert_file" >> "$GITHUB_ENV"
export NIX_SSL_CERT_FILE=$cert_file export NIX_SSL_CERT_FILE=$cert_file
sudo launchctl setenv NIX_SSL_CERT_FILE "$cert_file" sudo launchctl setenv NIX_SSL_CERT_FILE "$cert_file"
fi fi
# Set paths # Set paths
echo "::add-path::/nix/var/nix/profiles/per-user/$USER/profile/bin" echo "/nix/var/nix/profiles/per-user/$USER/profile/bin" >> "$GITHUB_PATH"
echo "::add-path::/nix/var/nix/profiles/default/bin" echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
if [[ $INPUT_NIX_PATH != "" ]]; then if [[ $INPUT_NIX_PATH != "" ]]; then
echo "::set-env name=NIX_PATH::${INPUT_NIX_PATH}" echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
fi fi

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"
}, },

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"
@ -1452,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"