|
| 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 | + nix-package-url: |
| 24 | + description: 'URL to download Nix package from' |
| 25 | + default: '' |
| 26 | + proxy: |
| 27 | + description: 'Proxy URL for downloads' |
| 28 | + default: '' |
| 29 | + ssl-cert-file: |
| 30 | + description: 'Path to SSL certificate file' |
| 31 | + default: '' |
| 32 | + modify-profile: |
| 33 | + description: 'Modify user profile to set up environment' |
| 34 | + default: 'true' |
| 35 | + daemon: |
| 36 | + description: 'Use daemon mode' |
| 37 | + default: 'true' |
| 38 | + init: |
| 39 | + description: 'Init mode for installation' |
| 40 | + default: 'systemd' |
| 41 | + start-daemon: |
| 42 | + description: 'Start the Nix daemon after installation' |
| 43 | + default: 'true' |
| 44 | + trust-runner-user: |
| 45 | + description: 'Add runner user to trusted users' |
| 46 | + default: 'true' |
| 47 | + flake-registry: |
| 48 | + description: 'Flake registry URL' |
| 49 | + default: '' |
| 50 | + channels: |
| 51 | + description: 'Nix channels to add' |
| 52 | + default: 'nixpkgs=https://nixos.org/channels/nixpkgs-unstable' |
| 53 | + |
| 54 | +outputs: |
| 55 | + nix-version: |
| 56 | + description: 'The version of Nix that was installed' |
| 57 | + value: ${{ steps.nix-install.outputs.nix-version }} |
| 58 | + |
| 59 | +runs: |
| 60 | + using: "composite" |
| 61 | + steps: |
| 62 | + - name: Download and install experimental Nix installer |
| 63 | + id: nix-install |
| 64 | + shell: bash |
| 65 | + env: |
| 66 | + NIX_INSTALLER_EXTRA_CONF: ${{ inputs.extra-conf }} |
| 67 | + NIX_INSTALLER_LOGGER: ${{ inputs.logger }} |
| 68 | + NIX_INSTALLER_NIX_BUILD_USER_COUNT: ${{ inputs.nix-build-user-count }} |
| 69 | + NIX_INSTALLER_NIX_BUILD_GROUP_NAME: ${{ inputs.nix-build-group-name }} |
| 70 | + NIX_INSTALLER_NIX_BUILD_GROUP_ID: ${{ inputs.nix-build-group-id }} |
| 71 | + NIX_INSTALLER_NIX_PACKAGE_URL: ${{ inputs.nix-package-url }} |
| 72 | + NIX_INSTALLER_PROXY: ${{ inputs.proxy }} |
| 73 | + NIX_INSTALLER_SSL_CERT_FILE: ${{ inputs.ssl-cert-file }} |
| 74 | + NIX_INSTALLER_MODIFY_PROFILE: ${{ inputs.modify-profile }} |
| 75 | + NIX_INSTALLER_DAEMON: ${{ inputs.daemon }} |
| 76 | + NIX_INSTALLER_INIT: ${{ inputs.init }} |
| 77 | + NIX_INSTALLER_START_DAEMON: ${{ inputs.start-daemon }} |
| 78 | + NIX_INSTALLER_TRUST_RUNNER_USER: ${{ inputs.trust-runner-user }} |
| 79 | + NIX_INSTALLER_FLAKE_REGISTRY: ${{ inputs.flake-registry }} |
| 80 | + NIX_INSTALLER_CHANNELS: ${{ inputs.channels }} |
| 81 | + run: | |
| 82 | + echo "Installing Nix using experimental installer..." |
| 83 | + |
| 84 | + # Download and run the experimental installer |
| 85 | + curl --proto '=https' --tlsv1.2 -sSf -L https://artifacts.nixos.org/experimental-installer | \ |
| 86 | + sh -s -- install |
| 87 | + |
| 88 | + # Source the nix profile to make nix available in current shell |
| 89 | + if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then |
| 90 | + source ~/.nix-profile/etc/profile.d/nix.sh |
| 91 | + elif [ -f /etc/profile.d/nix.sh ]; then |
| 92 | + source /etc/profile.d/nix.sh |
| 93 | + fi |
| 94 | + |
| 95 | + # Get Nix version and set output |
| 96 | + NIX_VERSION=$(nix --version | awk '{print $NF}') |
| 97 | + echo "nix-version=$NIX_VERSION" >> $GITHUB_OUTPUT |
| 98 | + echo "Installed Nix version: $NIX_VERSION" |
| 99 | + |
| 100 | + # Verify installation |
| 101 | + nix --version |
| 102 | + nix-env --version |
| 103 | +
|
| 104 | + - name: Add extra configuration |
| 105 | + if: inputs.extra-conf != '' |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + echo "Adding extra Nix configuration..." |
| 109 | + mkdir -p ~/.config/nix |
| 110 | + echo "${{ inputs.extra-conf }}" >> ~/.config/nix/nix.conf |
| 111 | + echo "Extra configuration added to nix.conf" |
| 112 | +
|
| 113 | + - name: Configure GitHub access token |
| 114 | + if: github.server_url == 'https://github.com' |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + echo "Configuring GitHub access token for Nix..." |
| 118 | + mkdir -p ~/.config/nix |
| 119 | + echo "access-tokens = github.com=${{ github.token }}" >> ~/.config/nix/nix.conf |
| 120 | + echo "GitHub access token configured" |
| 121 | +
|
| 122 | + - name: Verify Nix installation |
| 123 | + shell: bash |
| 124 | + run: | |
| 125 | + echo "Verifying Nix installation..." |
| 126 | + echo "Nix version: $(nix --version)" |
| 127 | + echo "Nix store info:" |
| 128 | + nix store info || echo "Store info not available" |
| 129 | + echo "Nix channels:" |
| 130 | + nix-channel --list || echo "No channels configured" |
0 commit comments