Skip to content

Commit 31cdba8

Browse files
authored
Try moving to Nix Experimental installer (#85)
1 parent ce104dc commit 31cdba8

File tree

2 files changed

+154
-5
lines changed

2 files changed

+154
-5
lines changed

action.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,48 @@ runs:
142142
mkdir -p ~/.config/nix
143143
echo "${{ inputs.extra-nix-config }}" >> ~/.config/nix/nix.conf
144144
145-
- name: Install nix
145+
- name: Download and install experimental Nix installer
146146
if: inputs.skip-nix-installation == 'false'
147-
uses: DeterminateSystems/nix-installer-action@786fff0690178f1234e4e1fe9b536e94f5433196 # v20
148-
with:
149-
logger: pretty
150-
extra-conf: experimental-features = ca-derivations fetch-closure
147+
shell: bash
148+
env:
149+
NIX_INSTALLER_EXTRA_CONF: experimental-features = ca-derivations fetch-closure nix-command flakes
150+
NIX_INSTALLER_LOGGER: pretty
151+
NIX_INSTALLER_NIX_BUILD_USER_COUNT: 32
152+
NIX_INSTALLER_NIX_BUILD_GROUP_NAME: nixbld
153+
NIX_INSTALLER_NIX_BUILD_GROUP_ID: 30000
154+
NIX_INSTALLER_MODIFY_PROFILE: true
155+
NIX_INSTALLER_INIT: systemd
156+
NIX_INSTALLER_START_DAEMON: true
157+
NIX_INSTALLER_TRUST_RUNNER_USER: true
158+
NIX_INSTALLER_CHANNELS: nixpkgs=https://nixos.org/channels/nixpkgs-unstable
159+
run: |
160+
echo "Installing Nix using experimental installer..."
161+
162+
# Download and run the experimental installer
163+
curl --proto '=https' --tlsv1.2 -sSf -L https://artifacts.nixos.org/experimental-installer | \
164+
sh -s -- install --no-confirm
165+
166+
# Source the nix profile to make nix available in current shell
167+
if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
168+
source ~/.nix-profile/etc/profile.d/nix.sh
169+
elif [ -f /etc/profile.d/nix.sh ]; then
170+
source /etc/profile.d/nix.sh
171+
fi
172+
173+
# Verify installation
174+
nix --version
175+
nix-env --version
176+
177+
- name: Verify Nix installation
178+
if: inputs.skip-nix-installation == 'false'
179+
shell: bash
180+
run: |
181+
echo "Verifying Nix installation..."
182+
echo "Nix version: $(nix --version)"
183+
echo "Nix store info:"
184+
nix store info || echo "Store info not available"
185+
echo "Nix channels:"
186+
nix-channel --list || echo "No channels configured"
151187
152188
- name: Get nix version
153189
shell: bash
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: 'Experimental Nix Installer'
2+
description: 'Install Nix using the experimental installer'
3+
branding:
4+
icon: 'box'
5+
color: 'blue'
6+
7+
inputs:
8+
extra-conf:
9+
description: 'Extra configuration to add to nix.conf'
10+
default: ''
11+
logger:
12+
description: 'Logger format (compact, full, pretty)'
13+
default: 'pretty'
14+
nix-build-user-count:
15+
description: 'Number of build users to create'
16+
default: '32'
17+
nix-build-group-name:
18+
description: 'Name of the build group'
19+
default: 'nixbld'
20+
nix-build-group-id:
21+
description: 'GID of the build group'
22+
default: '30000'
23+
modify-profile:
24+
description: 'Modify user profile to set up environment'
25+
default: 'true'
26+
daemon:
27+
description: 'Use daemon mode'
28+
default: 'true'
29+
init:
30+
description: 'Init mode for installation'
31+
default: 'systemd'
32+
start-daemon:
33+
description: 'Start the Nix daemon after installation'
34+
default: 'true'
35+
trust-runner-user:
36+
description: 'Add runner user to trusted users'
37+
default: 'true'
38+
channels:
39+
description: 'Nix channels to add'
40+
default: 'nixpkgs=https://nixos.org/channels/nixpkgs-unstable'
41+
42+
outputs:
43+
nix-version:
44+
description: 'The version of Nix that was installed'
45+
value: ${{ steps.nix-install.outputs.nix-version }}
46+
47+
runs:
48+
using: "composite"
49+
steps:
50+
- name: Download and install experimental Nix installer
51+
id: nix-install
52+
shell: bash
53+
env:
54+
NIX_INSTALLER_EXTRA_CONF: ${{ inputs.extra-conf }}
55+
NIX_INSTALLER_LOGGER: ${{ inputs.logger }}
56+
NIX_INSTALLER_NIX_BUILD_USER_COUNT: ${{ inputs.nix-build-user-count }}
57+
NIX_INSTALLER_NIX_BUILD_GROUP_NAME: ${{ inputs.nix-build-group-name }}
58+
NIX_INSTALLER_NIX_BUILD_GROUP_ID: ${{ inputs.nix-build-group-id }}
59+
NIX_INSTALLER_MODIFY_PROFILE: ${{ inputs.modify-profile }}
60+
NIX_INSTALLER_INIT: ${{ inputs.init }}
61+
NIX_INSTALLER_START_DAEMON: ${{ inputs.start-daemon }}
62+
NIX_INSTALLER_TRUST_RUNNER_USER: ${{ inputs.trust-runner-user }}
63+
NIX_INSTALLER_CHANNELS: ${{ inputs.channels }}
64+
run: |
65+
echo "Installing Nix using experimental installer..."
66+
67+
# Download and run the experimental installer
68+
curl --proto '=https' --tlsv1.2 -sSf -L https://artifacts.nixos.org/experimental-installer | \
69+
sh -s -- install --no-confirm
70+
71+
# Source the nix profile to make nix available in current shell
72+
if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
73+
source ~/.nix-profile/etc/profile.d/nix.sh
74+
elif [ -f /etc/profile.d/nix.sh ]; then
75+
source /etc/profile.d/nix.sh
76+
fi
77+
78+
# Get Nix version and set output
79+
NIX_VERSION=$(nix --version | awk '{print $NF}')
80+
echo "nix-version=$NIX_VERSION" >> $GITHUB_OUTPUT
81+
echo "Installed Nix version: $NIX_VERSION"
82+
83+
# Verify installation
84+
nix --version
85+
nix-env --version
86+
87+
- name: Add extra configuration
88+
if: inputs.extra-conf != ''
89+
shell: bash
90+
run: |
91+
echo "Adding extra Nix configuration..."
92+
mkdir -p ~/.config/nix
93+
echo "${{ inputs.extra-conf }}" >> ~/.config/nix/nix.conf
94+
echo "Extra configuration added to nix.conf"
95+
96+
- name: Configure GitHub access token
97+
if: github.server_url == 'https://github.com'
98+
shell: bash
99+
run: |
100+
echo "Configuring GitHub access token for Nix..."
101+
mkdir -p ~/.config/nix
102+
echo "access-tokens = github.com=${{ github.token }}" >> ~/.config/nix/nix.conf
103+
echo "GitHub access token configured"
104+
105+
- name: Verify Nix installation
106+
shell: bash
107+
run: |
108+
echo "Verifying Nix installation..."
109+
echo "Nix version: $(nix --version)"
110+
echo "Nix store info:"
111+
nix store info || echo "Store info not available"
112+
echo "Nix channels:"
113+
nix-channel --list || echo "No channels configured"

0 commit comments

Comments
 (0)