Skip to content

Commit dcdf545

Browse files
committed
feat: make nix installer init system configurable
Add a new `installer-init-system` input to action.yml that allows callers to configure the init system passed to the nix experimental installer via NIX_INSTALLER_INIT. Defaults to 'systemd' to preserve existing behaviour. Add a CI test job `test-action-with-no-init-system` that exercises the action with `installer-init-system: none`.
1 parent 8c6a66e commit dcdf545

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/test.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,13 @@ jobs:
108108
- name: Check nix user-agent-suffix config
109109
run: |
110110
[[ "$(nix config show user-agent-suffix)" == "test-suffix" ]]
111+
112+
test-action-with-no-init-system:
113+
runs-on: ubuntu-latest
114+
steps:
115+
- uses: actions/checkout@v4
116+
- name: Install devbox with no init system
117+
uses: ./
118+
with:
119+
project-path: 'testdata'
120+
installer-init-system: none

action.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ inputs:
2828
extra-nix-config:
2929
description: 'Gets appended to `nix.conf` if passed'
3030
default: ''
31-
31+
installer-init-system:
32+
description: 'The init system to use for the nix installer'
33+
default: 'systemd'
3234
runs:
3335
using: "composite"
3436
steps:
@@ -152,24 +154,24 @@ runs:
152154
NIX_INSTALLER_NIX_BUILD_GROUP_NAME: nixbld
153155
NIX_INSTALLER_NIX_BUILD_GROUP_ID: 30000
154156
NIX_INSTALLER_MODIFY_PROFILE: true
155-
NIX_INSTALLER_INIT: systemd
157+
NIX_INSTALLER_INIT: ${{ inputs.installer-init-system }}
156158
NIX_INSTALLER_START_DAEMON: true
157159
NIX_INSTALLER_TRUST_RUNNER_USER: true
158160
NIX_INSTALLER_CHANNELS: nixpkgs=https://nixos.org/channels/nixpkgs-unstable
159161
run: |
160162
echo "Installing Nix using experimental installer..."
161-
163+
162164
# Download and run the experimental installer
163165
curl --proto '=https' --tlsv1.2 -sSf -L https://artifacts.nixos.org/experimental-installer | \
164166
sh -s -- install --no-confirm
165-
167+
166168
# Source the nix profile to make nix available in current shell
167169
if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
168170
source ~/.nix-profile/etc/profile.d/nix.sh
169171
elif [ -f /etc/profile.d/nix.sh ]; then
170172
source /etc/profile.d/nix.sh
171173
fi
172-
174+
173175
# Verify installation
174176
nix --version
175177
nix-env --version

0 commit comments

Comments
 (0)