From 10a7d51bce0ae08f4e3e75b2db1a82257469ad57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Wed, 27 May 2020 13:17:01 +0200 Subject: [PATCH] allow skipping channel installation --- .github/workflows/test.yml | 21 +++++++++++++++++---- action.yml | 2 ++ lib/install-nix.sh | 14 +++++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53f9679..858bf10 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: pull_request: push: jobs: - tests: + simple-build: strategy: matrix: os: [ubuntu-latest, macos-latest] @@ -14,10 +14,23 @@ jobs: - run: yarn build - name: Install Nix uses: ./ - with: - install_url: https://static.domenkozar.com/install-2.3.5-pre - - run: nix-env -iA cachix -f https://github.com/NixOS/nixpkgs/tarball/ab5863afada3c1b50fc43bf774b75ea71b287cde + - 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 + no-channel: + 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: + skip_adding_nixpkgs_channel: true + - run: nix-build test.nix && exit 1 || echo "OK" + - run: NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/tarball/ab5863afada3c1b50fc43bf774b75ea71b287cde nix-build test.nix \ No newline at end of file diff --git a/action.yml b/action.yml index d54e033..edeb03a 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,8 @@ author: 'Domen Kožar' inputs: install_url: description: 'Installation URL that will contain a script to install Nix' + skip_adding_nixpkgs_channel: + description: 'Skip adding nixpkgs-unstable channel' branding: color: 'blue' icon: 'sun' diff --git a/lib/install-nix.sh b/lib/install-nix.sh index 4ba8ebc..703a958 100755 --- a/lib/install-nix.sh +++ b/lib/install-nix.sh @@ -6,8 +6,14 @@ sudo sh -c 'echo max-jobs = auto >> /tmp/nix.conf' # Allow binary caches for runner user sudo sh -c 'echo trusted-users = root runner >> /tmp/nix.conf' -sh <(curl -L ${INPUT_INSTALL_URL:-https://nixos.org/nix/install}) \ - --daemon --daemon-user-count 4 --nix-extra-conf-file /tmp/nix.conf --darwin-use-unencrypted-nix-store-volume +if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL = "true" ]]; then + extra_cmd=--no-channel-add +else + extra_cmd= +fi + +sh <(curl -L ${INPUT_INSTALL_URL:-https://static.domenkozar.com/install-2.3.5-pre}) \ + --daemon --daemon-user-count 4 --nix-extra-conf-file /tmp/nix.conf --darwin-use-unencrypted-nix-store-volume $extra_cmd if [[ $OSTYPE =~ darwin ]]; then # Disable spotlight indexing of /nix to speed up performance @@ -23,4 +29,6 @@ fi # Set paths echo "::add-path::/nix/var/nix/profiles/per-user/runner/profile/bin" echo "::add-path::/nix/var/nix/profiles/default/bin" -echo "::set-env name=NIX_PATH::/nix/var/nix/profiles/per-user/root/channels" \ No newline at end of file +if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL != "true" ]]; then +echo "::set-env name=NIX_PATH::/nix/var/nix/profiles/per-user/root/channels" +fi \ No newline at end of file