Compare commits

..

30 Commits

Author SHA1 Message Date
8d6d5e9496 freshen up README 2021-04-02 15:01:55 +02:00
20dc92e361 Merge pull request #71 from cachix/update-installer
update flakes
2021-04-02 14:53:35 +02:00
c5dad0de4e update flakes 2021-04-02 14:46:47 +02:00
36ed3fe72b Merge pull request #70 from cachix/dependabot/npm_and_yarn/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1
2021-04-01 10:54:40 +02:00
0b249633ac Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-31 02:04:33 +00:00
0bd2cdca25 Merge pull request #69 from cachix/test-installer-options
test installer options
2021-02-21 15:51:26 +00:00
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
6 changed files with 98 additions and 37 deletions

View File

@ -9,10 +9,10 @@ jobs:
simple-build:
strategy:
matrix:
os: [ubuntu-latest, macos-11.0]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2.3.4
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
@ -31,7 +31,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2.3.4
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
@ -47,7 +47,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2.3.4
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
@ -58,3 +58,38 @@ jobs:
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.3.4
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Install Nix
uses: ./
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
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://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
- run: nix-build test.nix

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 [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
@ -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 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
@ -30,16 +32,13 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v11
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixos-unstable
- 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
@ -52,18 +51,18 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v12
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v11
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-3.0pre20200820_4d77513/install
install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix-build
```
To install Nix from any commit, go to [the corresponding installer_test action](https://github.com/NixOS/nix/runs/2219534360) and click on "Run cachix/install-nix-action@XX" step and expand the first line.
## 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)
@ -76,15 +75,30 @@ jobs:
## 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 with the channel I have configured?
### 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.](https://github.com/actions/virtual-environments/issues/183#issuecomment-610723516).
### How can I install packages via nix-env from the specified `nix_path`?
```
nix-env -i mypackage -f '<nixpkgs>'
```
## Hacking
Install the dependencies

View File

@ -3,7 +3,9 @@ description: 'Installs Nix on GitHub Actions for the supported platforms: Linux
author: 'Domen Kožar'
inputs:
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:
description: 'Set NIX_PATH environment variable.'
extra_nix_config:

View File

@ -1,6 +1,11 @@
#!/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
@ -22,7 +27,12 @@ installer_options=(
--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
@ -35,15 +45,15 @@ if [[ $OSTYPE =~ darwin ]]; then
# macOS needs certificates hints
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
sudo launchctl setenv NIX_SSL_CERT_FILE "$cert_file"
fi
# Set paths
echo "::add-path::/nix/var/nix/profiles/per-user/$USER/profile/bin"
echo "::add-path::/nix/var/nix/profiles/default/bin"
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 "::set-env name=NIX_PATH::${INPUT_NIX_PATH}"
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
fi

View File

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

View File

@ -2,10 +2,10 @@
# yarn lockfile v1
"@actions/core@^1.1.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.1.1.tgz#e08f3dbfe04721bb3d040f8fca2d6d7e1817b2e1"
integrity sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==
"@actions/core@^1.1.0", "@actions/core@^1.2.6":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
"@actions/exec@^1.0.1":
version "1.0.1"
@ -1452,9 +1452,9 @@ inherits@2, inherits@~2.0.3:
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
ini@~1.3.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
version "1.3.8"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==
invariant@^2.2.4:
version "2.2.4"
@ -3630,9 +3630,9 @@ xml-name-validator@^3.0.0:
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
y18n@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
version "4.0.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
yallist@^3.0.0, yallist@^3.0.3:
version "3.1.0"