mirror of
https://github.com/nmattia/niv.git
synced 2024-09-18 19:07:19 +03:00
Add cachix
This commit is contained in:
parent
2ecfd86b63
commit
6cf4ff85b9
5
.github/actions/nix/action.yml
vendored
Normal file
5
.github/actions/nix/action.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
name: 'nix'
|
||||
description: 'use nix'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'main.js'
|
35
.github/actions/nix/install-nix
vendored
Executable file
35
.github/actions/nix/install-nix
vendored
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim: set ft=bash
|
||||
# adapted from https://github.com/cachix/install-nix-action/blob/master/src/main.ts
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sudo mkdir -p /etc/nix
|
||||
|
||||
# Workaround segfault: https://github.com/NixOS/nix/issues/2733
|
||||
sudo sh -c 'echo "http2 = false" >> /etc/nix/nix.conf'
|
||||
|
||||
|
||||
if [[ $OSTYPE =~ darwin ]]; then
|
||||
echo "Installing on Darwin"
|
||||
sudo sh -c "echo \"nix\t/opt/nix\" >> /etc/synthetic.conf"
|
||||
sudo sh -c "mkdir -m 0755 /opt/nix && chown runner /opt/nix"
|
||||
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B
|
||||
sudo sh -c "echo 'Defaults env_keep += NIX_IGNORE_SYMLINK_STORE' >> /etc/sudoers"
|
||||
echo "::set-env name=NIX_IGNORE_SYMLINK_STORE::1"
|
||||
export NIX_IGNORE_SYMLINK_STORE=1
|
||||
sudo launchctl setenv NIX_IGNORE_SYMLINK_STORE 1
|
||||
|
||||
cert_file=~/.nix-profile/etc/ssl/certs/ca-bundle.crt
|
||||
echo "::set-env name=NIX_SSL_CERT_FILE::$cert_file"
|
||||
export NIX_SSL_CERT_FILE=$cert_file
|
||||
sudo launchctl setenv NIX_SSL_CERT_FILE "$cert_file"
|
||||
fi
|
||||
|
||||
curl https://nixos.org/nix/install | sh
|
||||
|
||||
sudo sh -c 'echo "substituters = https://cache.nixos.org https://niv.cachix.org" > /etc/nix/nix.conf'
|
||||
sudo sh -c 'echo "trusted-public-keys = niv.cachix.org-1:X32PCg2e/zAm3/uD1ScqW2z/K0LtDyNV7RdaxIuLgQM= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" >> /etc/nix/nix.conf'
|
||||
|
||||
echo "::add-path::/nix/var/nix/profiles/per-user/runner/profile/bin"
|
||||
echo "::add-path::/nix/var/nix/profiles/default/bin"
|
2
.github/actions/nix/main.js
vendored
Normal file
2
.github/actions/nix/main.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
const { execFileSync } = require('child_process');
|
||||
execFileSync(`${__dirname}/install-nix`, { stdio: 'inherit' });
|
20
.github/workflows/test.yml
vendored
20
.github/workflows/test.yml
vendored
@ -12,5 +12,21 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: cachix/install-nix-action@v6
|
||||
- run: ./script/test
|
||||
- uses: './.github/actions/nix'
|
||||
- name: "Run tests"
|
||||
run: |
|
||||
|
||||
ls ~/.nix-profile/etc/
|
||||
echo "$NIX_SSL_CERT_FILE"
|
||||
./script/test
|
||||
- name: "Save cache"
|
||||
run: |
|
||||
if [ -n "$CACHIX_SIGNING_KEY" ]
|
||||
then
|
||||
nix-env -iA cachix -f https://cachix.org/api/v1/install
|
||||
nix path-info --all | cachix push niv
|
||||
else
|
||||
echo "CACHIX_SIGNING_KEY not set, not uploading cache"
|
||||
fi
|
||||
env:
|
||||
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
|
||||
|
Loading…
Reference in New Issue
Block a user