Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ runs:

- name: Install nix
if: inputs.skip-nix-installation == 'false'
uses: DeterminateSystems/nix-installer-action@90bb610b90bf290cad97484ba341453bd1cbefea # v19
uses: ./experimental-nix-installer
with:
logger: pretty
extra-conf: experimental-features = ca-derivations fetch-closure
extra-conf: experimental-features = ca-derivations fetch-closure nix-command flakes

- name: Get nix version
shell: bash
Expand Down
113 changes: 113 additions & 0 deletions experimental-nix-installer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: 'Experimental Nix Installer'
description: 'Install Nix using the experimental installer'
branding:
icon: 'box'
color: 'blue'

inputs:
extra-conf:
description: 'Extra configuration to add to nix.conf'
default: ''
logger:
description: 'Logger format (compact, full, pretty)'
default: 'pretty'
nix-build-user-count:
description: 'Number of build users to create'
default: '32'
nix-build-group-name:
description: 'Name of the build group'
default: 'nixbld'
nix-build-group-id:
description: 'GID of the build group'
default: '30000'
modify-profile:
description: 'Modify user profile to set up environment'
default: 'true'
daemon:
description: 'Use daemon mode'
default: 'true'
init:
description: 'Init mode for installation'
default: 'systemd'
start-daemon:
description: 'Start the Nix daemon after installation'
default: 'true'
trust-runner-user:
description: 'Add runner user to trusted users'
default: 'true'
channels:
description: 'Nix channels to add'
default: 'nixpkgs=https://nixos.org/channels/nixpkgs-unstable'

outputs:
nix-version:
description: 'The version of Nix that was installed'
value: ${{ steps.nix-install.outputs.nix-version }}

runs:
using: "composite"
steps:
- name: Download and install experimental Nix installer
id: nix-install
shell: bash
env:
NIX_INSTALLER_EXTRA_CONF: ${{ inputs.extra-conf }}
NIX_INSTALLER_LOGGER: ${{ inputs.logger }}
NIX_INSTALLER_NIX_BUILD_USER_COUNT: ${{ inputs.nix-build-user-count }}
NIX_INSTALLER_NIX_BUILD_GROUP_NAME: ${{ inputs.nix-build-group-name }}
NIX_INSTALLER_NIX_BUILD_GROUP_ID: ${{ inputs.nix-build-group-id }}
NIX_INSTALLER_MODIFY_PROFILE: ${{ inputs.modify-profile }}
NIX_INSTALLER_INIT: ${{ inputs.init }}
NIX_INSTALLER_START_DAEMON: ${{ inputs.start-daemon }}
NIX_INSTALLER_TRUST_RUNNER_USER: ${{ inputs.trust-runner-user }}
NIX_INSTALLER_CHANNELS: ${{ inputs.channels }}
run: |
echo "Installing Nix using experimental installer..."

# Download and run the experimental installer
curl --proto '=https' --tlsv1.2 -sSf -L https://artifacts.nixos.org/experimental-installer | \
sh -s -- install --no-confirm

# Source the nix profile to make nix available in current shell
if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
source ~/.nix-profile/etc/profile.d/nix.sh
elif [ -f /etc/profile.d/nix.sh ]; then
source /etc/profile.d/nix.sh
fi

# Get Nix version and set output
NIX_VERSION=$(nix --version | awk '{print $NF}')
echo "nix-version=$NIX_VERSION" >> $GITHUB_OUTPUT
echo "Installed Nix version: $NIX_VERSION"

# Verify installation
nix --version
nix-env --version

- name: Add extra configuration
if: inputs.extra-conf != ''
shell: bash
run: |
echo "Adding extra Nix configuration..."
mkdir -p ~/.config/nix
echo "${{ inputs.extra-conf }}" >> ~/.config/nix/nix.conf
echo "Extra configuration added to nix.conf"

- name: Configure GitHub access token
if: github.server_url == 'https://github.com'
shell: bash
run: |
echo "Configuring GitHub access token for Nix..."
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ github.token }}" >> ~/.config/nix/nix.conf
echo "GitHub access token configured"

- name: Verify Nix installation
shell: bash
run: |
echo "Verifying Nix installation..."
echo "Nix version: $(nix --version)"
echo "Nix store info:"
nix store info || echo "Store info not available"
echo "Nix channels:"
nix-channel --list || echo "No channels configured"
Loading