diff --git a/action.yml b/action.yml index 181f930..8357f88 100644 --- a/action.yml +++ b/action.yml @@ -142,12 +142,48 @@ runs: mkdir -p ~/.config/nix echo "${{ inputs.extra-nix-config }}" >> ~/.config/nix/nix.conf - - name: Install nix + - name: Download and install experimental Nix installer if: inputs.skip-nix-installation == 'false' - uses: DeterminateSystems/nix-installer-action@90bb610b90bf290cad97484ba341453bd1cbefea # v19 - with: - logger: pretty - extra-conf: experimental-features = ca-derivations fetch-closure + shell: bash + env: + NIX_INSTALLER_EXTRA_CONF: experimental-features = ca-derivations fetch-closure nix-command flakes + NIX_INSTALLER_LOGGER: pretty + NIX_INSTALLER_NIX_BUILD_USER_COUNT: 32 + NIX_INSTALLER_NIX_BUILD_GROUP_NAME: nixbld + NIX_INSTALLER_NIX_BUILD_GROUP_ID: 30000 + NIX_INSTALLER_MODIFY_PROFILE: true + NIX_INSTALLER_INIT: systemd + NIX_INSTALLER_START_DAEMON: true + NIX_INSTALLER_TRUST_RUNNER_USER: true + NIX_INSTALLER_CHANNELS: nixpkgs=https://nixos.org/channels/nixpkgs-unstable + 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 + + # Verify installation + nix --version + nix-env --version + + - name: Verify Nix installation + if: inputs.skip-nix-installation == 'false' + 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" - name: Get nix version shell: bash diff --git a/experimental-nix-installer/action.yml b/experimental-nix-installer/action.yml new file mode 100644 index 0000000..ae351d1 --- /dev/null +++ b/experimental-nix-installer/action.yml @@ -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"