1
1
mirror of https://github.com/nmattia/niv.git synced 2024-09-18 19:07:19 +03:00

Cleanup nix action

This commit is contained in:
Nicolas Mattia 2020-02-23 10:18:59 +01:00
parent f2e2502412
commit 7d70c37ab0
2 changed files with 38 additions and 17 deletions

View File

@ -4,12 +4,15 @@
set -euo pipefail
set -x
echo "Installing Nix"
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"
@ -28,8 +31,37 @@ 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"
PATH="/nix/var/nix/profiles/per-user/runner/profile/bin:$PATH"
PATH="/nix/var/nix/profiles/default/bin:$PATH"
echo "Installing cachix"
nix-env -iA cachix -f https://cachix.org/api/v1/install
echo "Setting up cachix"
cachix_cache="${GITHUB_REPOSITORY##*/}"
echo "Using cache '$cachix_cache' for '$GITHUB_REPOSITORY'"
cachix use "$cachix_cache"
script_path="$HOME/.local/bin/save-cache"
mkdir -p "$(dirname $script_path)"
cat <<EOF >> "$script_path"
#!/usr/bin/env bash
if [ -n "\$CACHIX_SIGNING_KEY" ];
then
nix path-info --all | cachix push $cachix_cache
else
echo "CACHIX_SIGNING_KEY not set, not uploading cache"
fi
EOF
chmod +x "$script_path"
echo "::add-path::$(dirname $script_path)"

View File

@ -14,19 +14,8 @@ jobs:
- uses: actions/checkout@v1
- uses: './.github/actions/nix'
- name: "Run tests"
run: |
ls ~/.nix-profile/etc/
echo "$NIX_SSL_CERT_FILE"
./script/test
run: ./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
run: save-cache
env:
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}