2022-12-23 17:49:23 +00:00
name : Nix Installer
branding :
icon : 'box'
color : 'purple'
description : An experimental Nix installer using `nix-install`
2022-12-16 18:55:28 +00:00
inputs :
planner :
description : A planner to use
required : false
extra-args :
description : Extra args to pass to the planner (prefer using structured `with:` arguments unless using a custom planner!)
required : false
github-token :
description : A Github Token so that authenticated requests can be made (set this to `secrets.GITHUB_TOKEN`)
channels :
description : Channel(s) to add (eg `nixpkgs=https://nixos.org/channels/nixpkgs-unstable`)
required : false
modify-profile :
description : Modify the user profile to automatically load nix
required : false
2023-01-09 18:31:37 +00:00
nix-build-user-count :
2022-12-16 18:55:28 +00:00
description : Number of build users to create
required : false
nix-build-group-name :
description : The Nix build group name
required : false
nix-build-group-id :
description : The Nix build group GID
required : false
nix-build-user-prefix :
description : The Nix build user prefix (user numbers will be postfixed)
required : false
nix-build-user-base :
description : The Nix build user base UID (ascending)
required : false
nix-package-url :
description : The Nix package URL
required : false
extra-conf :
description : Extra configuration lines for `/etc/nix.conf` (includes `access-tokens` with `secrets.GITHUB_TOKEN` automatically if `github-token` is set)
required : false
mac-encrypt :
description : Force encryption on the volume (Mac only)
required : false
mac-case-sensitive :
description : Use a case sensitive volume (Mac only)
required : false
mac-volume-label :
description : The label for the created APFS volume (Mac only)
required : false
mac-root-disk :
description : The root disk of the target (Mac only)
required : false
2022-12-19 18:26:58 +00:00
nix-installer-url :
description : A URL pointing to a `nix-installer.sh` script
2022-12-16 18:55:28 +00:00
required : true
default : https://install.determinate.systems/nix
local-root :
2022-12-19 18:26:58 +00:00
description : A local `nix-installer` binary root, overrides the `nix-installer-url` setting (a `nix-installer.sh` should exist, binaries should be named `nix-installer-$ARCH`, eg. `nix-installer-x86_64-linux`)
2022-12-16 18:55:28 +00:00
required : false
logger :
description : The logger to use for install (eg. `pretty`, `json`, `full`, `compact`)
required : false
log-directives :
2022-12-19 18:26:58 +00:00
description : A list of Tracing directives, comma separated, `-`s replaced with `_` (eg. `nix_installer=trace`, see https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives)
2022-12-16 18:55:28 +00:00
required : false
backtrace :
description : The setting for `RUST_BACKTRACE` (see https://doc.rust-lang.org/std/backtrace/index.html#environment-variables)
required : false
runs :
using : composite
steps :
- name : Install Nix
shell : bash
run : |
if [ -n "${{ inputs.channels }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_CHANNELS=${{ inputs.channels }}
echo "Set NIX_INSTALLER_CHANNELS=$NIX_INSTALLER_CHANNELS"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.modify-profile }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_MODIFY_PROFILE=${{ inputs.modify-profile }}
echo "Set NIX_INSTALLER_MODIFY_PROFILE=$NIX_INSTALLER_MODIFY_PROFILE"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.daemon-user-count }}" ]; then
2023-01-09 18:31:37 +00:00
export NIX_INSTALLER_NIX_BUILD_USER_COUNT=${{ inputs.nix-build-user-count }}
echo "Set NIX_INSTALLER_NIX_BUILD_USER_COUNT=$NIX_INSTALLER_NIX_BUILD_USER_COUNT"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.nix-build-group-name }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_NIX_BUILD_GROUP_NAME=${{ inputs.nix-build-group-name }}
echo "Set NIX_INSTALLER_NIX_BUILD_GROUP_NAME=$NIX_INSTALLER_NIX_BUILD_GROUP_NAME"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.nix-build-group-id }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_NIX_BUILD_GROUP_ID=${{ inputs.nix-build-group-id }}
echo "Set NIX_INSTALLER_NIX_BUILD_GROUP_ID=$NIX_INSTALLER_NIX_BUILD_GROUP_ID"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.nix-build-user-prefix }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=${{ inputs.nix-build-user-prefix }}
echo "Set NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=$NIX_INSTALLER_NIX_BUILD_USER_ID_BASE"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.nix-build-user-base }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_NIX_BUILD_USER_PREFIX=${{ inputs.nix-build-user-base }}
echo "Set NIX_INSTALLER_NIX_BUILD_USER_PREFIX=$NIX_INSTALLER_NIX_BUILD_USER_PREFIX"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.nix-package-url }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_NIX_PACKAGE_URL=${{ inputs.nix-package-url }}
echo "Set NIX_INSTALLER_NIX_PACKAGE_URL=$NIX_INSTALLER_NIX_PACKAGE_URL"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.extra-conf }}" ]; then
if [ -n "${{ inputs.github-token }}" ]; then
2022-12-23 18:43:55 +00:00
export NIX_INSTALLER_EXTRA_CONF="${{ inputs.extra-conf }}access-tokens = github.com=${{ inputs.github-token }}"
2022-12-16 18:55:28 +00:00
else
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_EXTRA_CONF="${{ inputs.extra-conf }}"
2022-12-16 18:55:28 +00:00
fi
2022-12-19 18:26:58 +00:00
echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF"
2022-12-16 18:55:28 +00:00
else
if [ -n "${{ inputs.github-token }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_EXTRA_CONF="access-tokens = github.com=${{ inputs.github-token }}"
echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF"
2022-12-16 18:55:28 +00:00
fi
fi
if [ -n "${{ inputs.mac-encrypt }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_ENCRYPT=${{ inputs.mac-encrypt }}
echo "Set NIX_INSTALLER_ENCRYPT=$NIX_INSTALLER_ENCRYPT"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.mac-case-sensitive }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_CASE_SENSITIVE=${{ inputs.mac-case-sensitive }}
echo "Set NIX_INSTALLER_CASE_SENSITIVE=$NIX_INSTALLER_CASE_SENSITIVE"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.mac-volume-label }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_VOLUME_LABEL=${{ inputs.mac-volume-label }}
echo "Set NIX_INSTALLER_VOLUME_LABEL=$NIX_INSTALLER_VOLUME_LABEL"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.mac-root-disk }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_ROOT_DISK=${{ inputs.mac-root-disk }}
echo "Set NIX_INSTALLER_ROOT_DISK=$NIX_INSTALLER_ROOT_DISK"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.local-root }}" ]; then
if [ "$RUNNER_OS" == "macOS" ]; then
export PYTHON="python3"
else
export PYTHON="python"
fi
$PYTHON -m http.server --directory ${{ inputs.local-root }} --bind 0.0.0.0 8000 &
export HTTP_PID=$!
echo "Started simple http server for ${{ inputs.local-root }} on 0.0.0.0:8000"
while (! ( : </dev/tcp/localhost/8000) &> /dev/null); do
sleep 1
done
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_FORCE_ALLOW_HTTP="1"
echo "Set NIX_INSTALLER_FORCE_ALLOW_HTTP=$NIX_INSTALLER_FORCE_ALLOW_HTTP"
export NIX_INSTALLER_URL=0.0.0.0:8000/nix-installer.sh
echo "Set NIX_INSTALLER_URL=$NIX_INSTALLER_URL"
export NIX_INSTALLER_BINARY_ROOT=http://0.0.0.0:8000/
echo "Set NIX_INSTALLER_BINARY_ROOT=$NIX_INSTALLER_BINARY_ROOT"
export NIX_INSTALLER_FORCE_ALLOW_HTTP=1
echo "Set NIX_INSTALLER_FORCE_ALLOW_HTTP=$NIX_INSTALLER_FORCE_ALLOW_HTTP"
2022-12-16 18:55:28 +00:00
else
2022-12-19 20:27:25 +00:00
export NIX_INSTALLER_URL=${{ inputs.nix-installer-url }}
2022-12-19 18:26:58 +00:00
echo "Set NIX_INSTALLER_URL=$NIX_INSTALLER_URL"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.logger }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_LOGGER=${{ inputs.logger }}
echo "Set NIX_INSTALLER_LOGGER=$NIX_INSTALLER_LOGGER"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.log-directives }}" ]; then
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_LOG_DIRECTIVES=${{ inputs.log-directives }}
echo "Set NIX_INSTALLER_LOG_DIRECTIVES=$NIX_INSTALLER_LOG_DIRECTIVES"
2022-12-16 18:55:28 +00:00
fi
if [ -n "${{ inputs.backtrace }}" ]; then
export RUST_BACKTRACE=${{ inputs.backtrace }}
echo "Set RUST_BACKTRACE=$RUST_BACKTRACE"
fi
2022-12-19 18:26:58 +00:00
export NIX_INSTALLER_NO_CONFIRM=true
echo "Set NIX_INSTALLER_NO_CONFIRM=$NIX_INSTALLER_NO_CONFIRM"
2022-12-16 18:55:28 +00:00
2022-12-19 18:26:58 +00:00
curl --retry 20 -L $NIX_INSTALLER_URL | sh -s -- install ${{ inputs.planner }} ${{ inputs.extra-args }}
2022-12-16 18:55:28 +00:00
if [ -n "$HTTP_PID" ]; then
kill $HTTP_PID
fi