Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cachix/install-nix-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v23
Choose a base ref
...
head repository: cachix/install-nix-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v24
Choose a head ref
  • 10 commits
  • 4 files changed
  • 6 contributors

Commits on Sep 5, 2023

  1. chore(deps): bump actions/checkout from 3 to 4

    Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v3...v4)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Sep 5, 2023
    Copy the full SHA
    fe6788c View commit details
  2. Merge pull request #193 from cachix/dependabot/github_actions/actions…

    …/checkout-4
    
    chore(deps): bump actions/checkout from 3 to 4
    domenkozar authored Sep 5, 2023
    Copy the full SHA
    300721f View commit details

Commits on Nov 3, 2023

  1. fix: Set TMPDIR to avoid disk space issues

    Set `TMPDIR` if not already set to workaround potential disk space
    issues while running builds in a nix shell. See NixOS/nix#395 for
    more info.
    
    fixes #197
    jalaziz committed Nov 3, 2023
    Copy the full SHA
    2cce1fd View commit details
  2. fix: don't use the default GitHub token for Enterprise

    The token on Enterprise instances is not valid for github.com.
    
    Resolves #196.
    sandydoo committed Nov 3, 2023
    Copy the full SHA
    97a1be3 View commit details
  3. Update install-nix.sh

    Co-authored-by: Domen Kožar <domen@enlambda.com>
    jalaziz and domenkozar authored Nov 3, 2023
    Copy the full SHA
    81eb746 View commit details

Commits on Nov 4, 2023

  1. Merge pull request #199 from jalaziz/tempdir

    fix: Set TMPDIR to avoid disk space issues
    domenkozar authored Nov 4, 2023
    Copy the full SHA
    a56e3a8 View commit details

Commits on Nov 22, 2023

  1. Copy the full SHA
    fe19c91 View commit details

Commits on Nov 23, 2023

  1. Merge pull request #202 from cachix/feature/kvm

    feat: enable KVM on Linux if available
    domenkozar authored Nov 23, 2023
    Copy the full SHA
    2b90cd3 View commit details

Commits on Nov 28, 2023

  1. Merge pull request #200 from cachix/fix/196

    fix: don't use the default GitHub token for Enterprise
    domenkozar authored Nov 28, 2023
    Copy the full SHA
    dc33a21 View commit details
  2. Nix 2.19.1

    domenkozar committed Nov 28, 2023
    Copy the full SHA
    7ac1ec2 View commit details
Showing with 40 additions and 10 deletions.
  1. +7 −7 .github/workflows/test.yml
  2. +2 −0 README.md
  3. +5 −0 action.yml
  4. +26 −3 install-nix.sh
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Nix
uses: ./
with:
@@ -28,7 +28,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Nix
uses: ./
with:
@@ -42,7 +42,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Nix
uses: ./
with:
@@ -58,7 +58,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Nix
uses: ./
- run: nix flake show github:NixOS/nixpkgs
@@ -69,7 +69,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Nix
uses: ./
with:
@@ -84,7 +84,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Nix
uses: ./
with:
@@ -98,7 +98,7 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
- run: docker pull ghcr.io/catthehacker/ubuntu:js-20.04
- run: ./bin/act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-20.04 push -j simple-build
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -73,6 +73,8 @@ To install Nix from any commit, go to [the corresponding installer_test action](

- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable`

- `enable_kvm`: whether to enable KVM for hardware-accelerated virtualization on Linux. Enabled by default if available.

---

## FAQ
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -12,6 +12,10 @@ inputs:
description: 'Additional installer flags passed to the installer script.'
nix_path:
description: 'Set NIX_PATH environment variable.'
enable_kvm:
description: 'Enable KVM for hardware-accelerated virtualization on Linux, if available.'
required: false
default: true
branding:
color: 'blue'
icon: 'sun'
@@ -26,4 +30,5 @@ runs:
INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }}
INPUT_INSTALL_URL: ${{ inputs.install_url }}
INPUT_NIX_PATH: ${{ inputs.nix_path }}
INPUT_ENABLE_KVM: ${{ inputs.enable_kvm }}
GITHUB_TOKEN: ${{ github.token }}
29 changes: 26 additions & 3 deletions install-nix.sh
Original file line number Diff line number Diff line change
@@ -6,6 +6,17 @@ if nix_path="$(type -p nix)" ; then
exit
fi

if [[ ($OSTYPE =~ linux) && ($INPUT_ENABLE_KVM == 'true') ]]; then
enable_kvm() {
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-install-nix-action-kvm.rules
sudo udevadm control --reload-rules && sudo udevadm trigger --name-match=kvm
}

echo '::group::Enabling KVM support'
enable_kvm && echo 'Enabled KVM' || echo 'KVM is not available'
echo '::endgroup::'
fi

# GitHub command to put the following log messages into a group which is collapsed by default
echo "::group::Installing Nix"

@@ -25,11 +36,18 @@ if [[ $OSTYPE =~ darwin ]]; then
fi
# Allow binary caches for user
add_config "trusted-users = root ${USER:-}"
# Add github access token
# Add a GitHub access token.
# Token-less access is subject to lower rate limits.
if [[ -n "${INPUT_GITHUB_ACCESS_TOKEN:-}" ]]; then
echo "::debug::Using the provided github_access_token for github.com"
add_config "access-tokens = github.com=$INPUT_GITHUB_ACCESS_TOKEN"
elif [[ -n "${GITHUB_TOKEN:-}" ]]; then
# Use the default GitHub token if available.
# Skip this step if running an Enterprise instance. The default token there does not work for github.com.
elif [[ -n "${GITHUB_TOKEN:-}" && $GITHUB_SERVER_URL == "https://github.com" ]]; then
echo "::debug::Using the default GITHUB_TOKEN for github.com"
add_config "access-tokens = github.com=$GITHUB_TOKEN"
else
echo "::debug::Continuing without a GitHub access token"
fi
# Append extra nix configuration if provided
if [[ -n "${INPUT_EXTRA_NIX_CONFIG:-}" ]]; then
@@ -70,7 +88,7 @@ echo "installer options: ${installer_options[*]}"

# There is --retry-on-errors, but only newer curl versions support that
curl_retries=5
while ! curl -sS -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://releases.nixos.org/nix/nix-2.17.0/install}"
while ! curl -sS -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://releases.nixos.org/nix/nix-2.19.1/install}"
do
sleep 1
((curl_retries--))
@@ -91,5 +109,10 @@ if [[ -n "${INPUT_NIX_PATH:-}" ]]; then
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"
fi

# Set temporary directory (if not already set) to fix https://github.com/cachix/install-nix-action/issues/197
if [[ -z "${TMPDIR:-}" ]]; then
echo "TMPDIR=${RUNNER_TEMP}" >> "$GITHUB_ENV"
fi

# Close the log message group which was opened above
echo "::endgroup::"