mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 05:22:21 +01:00
Typescript rewrite
This commit is contained in:
parent
3df486a535
commit
79baecff38
13 changed files with 9938 additions and 228 deletions
79
.eslintrc.json
Normal file
79
.eslintrc.json
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"plugin:github/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 9,
|
||||||
|
"sourceType": "module",
|
||||||
|
"project": "./tsconfig.json"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"i18n-text/no-en": "off",
|
||||||
|
"eslint-comments/no-use": "off",
|
||||||
|
"import/no-namespace": "off",
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"argsIgnorePattern": "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/explicit-member-accessibility": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"accessibility": "no-public"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-require-imports": "error",
|
||||||
|
"@typescript-eslint/array-type": "error",
|
||||||
|
"@typescript-eslint/await-thenable": "error",
|
||||||
|
"@typescript-eslint/ban-ts-comment": "error",
|
||||||
|
"camelcase": "off",
|
||||||
|
"@typescript-eslint/consistent-type-assertions": "error",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"allowExpressions": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/func-call-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-array-constructor": "error",
|
||||||
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"@typescript-eslint/no-extraneous-class": "error",
|
||||||
|
"@typescript-eslint/no-for-in-array": "error",
|
||||||
|
"@typescript-eslint/no-inferrable-types": "error",
|
||||||
|
"@typescript-eslint/no-misused-new": "error",
|
||||||
|
"@typescript-eslint/no-namespace": "error",
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||||
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||||
|
"@typescript-eslint/no-useless-constructor": "error",
|
||||||
|
"@typescript-eslint/no-var-requires": "error",
|
||||||
|
"@typescript-eslint/prefer-for-of": "warn",
|
||||||
|
"@typescript-eslint/prefer-function-type": "warn",
|
||||||
|
"@typescript-eslint/prefer-includes": "error",
|
||||||
|
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||||
|
"@typescript-eslint/promise-function-async": "error",
|
||||||
|
"@typescript-eslint/require-array-sort-compare": "error",
|
||||||
|
"@typescript-eslint/restrict-plus-operands": "error",
|
||||||
|
"semi": "off",
|
||||||
|
"@typescript-eslint/semi": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"@typescript-eslint/type-annotation-spacing": "error",
|
||||||
|
"@typescript-eslint/unbound-method": "error"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true
|
||||||
|
}
|
||||||
|
}
|
99
.gitignore
vendored
Normal file
99
.gitignore
vendored
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
# Dependency directory
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# OS metadata
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Ignore built ts files
|
||||||
|
__tests__/runner/*
|
||||||
|
lib/**/*
|
3
.prettierignore
Normal file
3
.prettierignore
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
dist/
|
||||||
|
lib/
|
||||||
|
node_modules/
|
10
.prettierrc.json
Normal file
10
.prettierrc.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"printWidth": 80,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"bracketSpacing": false,
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
232
action.yml
232
action.yml
|
@ -20,7 +20,7 @@ inputs:
|
||||||
description: "The init system to configure, requires `planner: linux-multi` (allowing the choice between `none` or `systemd`)"
|
description: "The init system to configure, requires `planner: linux-multi` (allowing the choice between `none` or `systemd`)"
|
||||||
required: false
|
required: false
|
||||||
local-root:
|
local-root:
|
||||||
description: A local `nix-installer` binary root, overrides the `nix-installer-url` setting (a `nix-installer.sh` script should exist, binaries should be named `nix-installer-$ARCH`, eg. `nix-installer-x86_64-linux`)
|
description: A local `nix-installer` binary root, overrides any settings which change the `nix-installer` used (binaries should be named `nix-installer-$ARCH`, eg. `nix-installer-x86_64-linux`)
|
||||||
required: false
|
required: false
|
||||||
log-directives:
|
log-directives:
|
||||||
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)
|
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)
|
||||||
|
@ -31,7 +31,7 @@ inputs:
|
||||||
ssl-cert-file:
|
ssl-cert-file:
|
||||||
description: "An SSL cert to use (if any), used for fetching Nix and sets `NIX_SSL_CERT_FILE` for Nix"
|
description: "An SSL cert to use (if any), used for fetching Nix and sets `NIX_SSL_CERT_FILE` for Nix"
|
||||||
required: false
|
required: false
|
||||||
pproxy:
|
proxy:
|
||||||
description: "The proxy to use (if any), valid proxy bases are `https://$URL`, `http://$URL` and `socks5://$URL`"
|
description: "The proxy to use (if any), valid proxy bases are `https://$URL`, `http://$URL` and `socks5://$URL`"
|
||||||
required: false
|
required: false
|
||||||
mac-case-sensitive:
|
mac-case-sensitive:
|
||||||
|
@ -99,229 +99,5 @@ inputs:
|
||||||
default: "true"
|
default: "true"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: "node16"
|
||||||
steps:
|
main: 'dist/index.js'
|
||||||
- name: Install Nix
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ -f "/nix/receipt.json" ] && [ -f "/nix/nix-installer" ]; then
|
|
||||||
if ([ -n "${{ inputs.nix-installer-revision }}" ] || [ -n "${{ inputs.nix-installer-branch }}" ]) && [ "${{ inputs.reinstall }}" != "true" ]; then
|
|
||||||
echo "Detection of existing installation versions isn't supported when \`nix-installer-revision\` or \`nix-installer-branch\` are set, \`reinstall: true\` should also be set"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.reinstall }}" ] && [ "${{ inputs.reinstall }}" == "true" ]; then
|
|
||||||
/nix/nix-installer uninstall --no-confirm
|
|
||||||
else
|
|
||||||
EXISTING_VERSION=$(/nix/nix-installer --version | awk '{ print $2 }')
|
|
||||||
if [ -n "${{ inputs.nix-installer-tag }}" ] && [ "${{ inputs.nix-installer-tag }}" != "$EXISTING_VERSION" ]; then
|
|
||||||
echo "`nix-installer` version mismatch, use `reinstall: true` to reinstall Nix using the new `nix-installer` version (consider backing up `/nix/store`)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Nix was already installed, using existing install"
|
|
||||||
echo "/nix/var/nix/profiles/default/bin" >> $GITHUB_PATH
|
|
||||||
echo "$HOME/.nix-profile/bin" >> $GITHUB_PATH
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
NIX_EXTRA_CONF_FILE=$(mktemp)
|
|
||||||
|
|
||||||
if [ -n "$ACT" ] && [ ! -n "$NOT_ACT" ]; then
|
|
||||||
echo 'Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the settings of the `init` as well as `extra-conf` to be compatible with `act`'
|
|
||||||
export NIX_INSTALLER_INIT="none"
|
|
||||||
echo "Set NIX_INSTALLER_INIT=$NIX_INSTALLER_INIT"
|
|
||||||
echo "sandbox = false" >> ${NIX_EXTRA_CONF_FILE}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.modify-profile }}" ]; then
|
|
||||||
export NIX_INSTALLER_MODIFY_PROFILE=${{ inputs.modify-profile }}
|
|
||||||
echo "Set NIX_INSTALLER_MODIFY_PROFILE=$NIX_INSTALLER_MODIFY_PROFILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-build-user-count }}" ]; then
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-build-group-name }}" ]; then
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-build-group-id }}" ]; then
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-build-user-prefix }}" ]; then
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-build-user-base }}" ]; then
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-package-url }}" ]; then
|
|
||||||
export NIX_INSTALLER_NIX_PACKAGE_URL=${{ inputs.nix-package-url }}
|
|
||||||
echo "Set NIX_INSTALLER_NIX_PACKAGE_URL=$NIX_INSTALLER_NIX_PACKAGE_URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.extra-conf }}" ]; then
|
|
||||||
echo "${{ inputs.extra-conf }}" >> ${NIX_EXTRA_CONF_FILE}
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.github-token }}" ]; then
|
|
||||||
echo "access-tokens = github.com=${{ inputs.github-token }}" >> ${NIX_EXTRA_CONF_FILE}
|
|
||||||
fi
|
|
||||||
if [ "${{ inputs.trust-runner-user }}" == "true" ]; then
|
|
||||||
echo "trusted-users = root $USER" >> ${NIX_EXTRA_CONF_FILE}
|
|
||||||
fi
|
|
||||||
if [ -n "$NIX_EXTRA_CONF_FILE" ]; then
|
|
||||||
export NIX_INSTALLER_EXTRA_CONF=$(cat ${NIX_EXTRA_CONF_FILE})
|
|
||||||
echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.mac-encrypt }}" ]; then
|
|
||||||
export NIX_INSTALLER_ENCRYPT=${{ inputs.mac-encrypt }}
|
|
||||||
echo "Set NIX_INSTALLER_ENCRYPT=$NIX_INSTALLER_ENCRYPT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.mac-case-sensitive }}" ]; then
|
|
||||||
export NIX_INSTALLER_CASE_SENSITIVE=${{ inputs.mac-case-sensitive }}
|
|
||||||
echo "Set NIX_INSTALLER_CASE_SENSITIVE=$NIX_INSTALLER_CASE_SENSITIVE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.mac-volume-label }}" ]; then
|
|
||||||
export NIX_INSTALLER_VOLUME_LABEL=${{ inputs.mac-volume-label }}
|
|
||||||
echo "Set NIX_INSTALLER_VOLUME_LABEL=$NIX_INSTALLER_VOLUME_LABEL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.mac-root-disk }}" ]; then
|
|
||||||
export NIX_INSTALLER_ROOT_DISK=${{ inputs.mac-root-disk }}
|
|
||||||
echo "Set NIX_INSTALLER_ROOT_DISK=$NIX_INSTALLER_ROOT_DISK"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-installer-pr }}" ] && [ -n "${{ inputs.nix-installer-tag }}" ]; then
|
|
||||||
echo "The nix-installer-pr and nix-installer-tag options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-pr }}" ] && [ -n "${{ inputs.nix-installer-revision }}" ]; then
|
|
||||||
echo "The nix-installer-pr and nix-installer-revision options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-pr }}" ] && [ -n "${{ inputs.nix-installer-branch }}" ]; then
|
|
||||||
echo "The nix-installer-pr and nix-installer-branch options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-tag }}" ] && [ -n "${{ inputs.nix-installer-revision }}" ]; then
|
|
||||||
echo "The nix-installer-tag and nix-installer-revision options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-branch }}" ] && [ -n "${{ inputs.nix-installer-revision }}" ]; then
|
|
||||||
echo "The nix-installer-branch and nix-installer-revision options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-tag }}" ] && [ -n "${{ inputs.nix-installer-branch }}" ]; then
|
|
||||||
echo "The nix-installer-tag and nix-installer-branch options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-url }}" ] && [ -n "${{ inputs.nix-installer-pr }}" ]; then
|
|
||||||
echo "The nix-installer-url and nix-installer-pr options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-url }}" ] && [ -n "${{ inputs.nix-installer-tag }}" ]; then
|
|
||||||
echo "The nix-installer-url and nix-installer-tag options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "${{ inputs.nix-installer-url }}" ] && [ -n "${{ inputs.nix-installer-branch }}" ]; then
|
|
||||||
echo "The nix-installer-url and nix-installer-branch options conflict, please choose one"
|
|
||||||
exit 1
|
|
||||||
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
|
|
||||||
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"
|
|
||||||
else
|
|
||||||
if [ -n "${{ inputs.nix-installer-url }}" ]; then
|
|
||||||
export NIX_INSTALLER_URL="${{ inputs.nix-installer-url }}"
|
|
||||||
else
|
|
||||||
if [ -n "${{ inputs.nix-installer-pr }}" ]; then
|
|
||||||
export NIX_INSTALLER_URL="https://install.determinate.systems/nix/pr/${{ inputs.nix-installer-pr }}?ci=github"
|
|
||||||
elif [ -n "${{ inputs.nix-installer-tag }}" ]; then
|
|
||||||
export NIX_INSTALLER_URL="https://install.determinate.systems/nix/tag/${{ inputs.nix-installer-tag }}?ci=github"
|
|
||||||
elif [ -n "${{ inputs.nix-installer-revision }}" ]; then
|
|
||||||
export NIX_INSTALLER_URL="https://install.determinate.systems/nix/rev/${{ inputs.nix-installer-revision }}?ci=github"
|
|
||||||
elif [ -n "${{ inputs.nix-installer-branch }}" ]; then
|
|
||||||
export NIX_INSTALLER_URL="https://install.determinate.systems/nix/branch/${{ inputs.nix-installer-branch }}?ci=github"
|
|
||||||
else
|
|
||||||
export NIX_INSTALLER_URL="https://install.determinate.systems/nix?ci=github"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "Set NIX_INSTALLER_URL=$NIX_INSTALLER_URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.logger }}" ]; then
|
|
||||||
export NIX_INSTALLER_LOGGER=${{ inputs.logger }}
|
|
||||||
echo "Set NIX_INSTALLER_LOGGER=$NIX_INSTALLER_LOGGER"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.init }}" ]; then
|
|
||||||
export NIX_INSTALLER_INIT=${{ inputs.init }}
|
|
||||||
echo "Set NIX_INSTALLER_INIT=$NIX_INSTALLER_INIT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.start-daemon }}" ]; then
|
|
||||||
export NIX_INSTALLER_START_DAEMON=${{ inputs.start-daemon }}
|
|
||||||
echo "Set NIX_INSTALLER_START_DAEMON=$NIX_INSTALLER_START_DAEMON"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.log-directives }}" ]; then
|
|
||||||
export NIX_INSTALLER_LOG_DIRECTIVES=${{ inputs.log-directives }}
|
|
||||||
echo "Set NIX_INSTALLER_LOG_DIRECTIVES=$NIX_INSTALLER_LOG_DIRECTIVES"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.backtrace }}" ]; then
|
|
||||||
export RUST_BACKTRACE=${{ inputs.backtrace }}
|
|
||||||
echo "Set RUST_BACKTRACE=$RUST_BACKTRACE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.diagnostic-endpoint }}" ]; then
|
|
||||||
export NIX_INSTALLER_DIAGNOSTIC_ENDPOINT="${{ inputs.diagnostic-endpoint }}"
|
|
||||||
echo "Set NIX_INSTALLER_DIAGNOSTIC_ENDPOINT=$NIX_INSTALLER_DIAGNOSTIC_ENDPOINT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export NIX_INSTALLER_NO_CONFIRM=true
|
|
||||||
echo "Set NIX_INSTALLER_NO_CONFIRM=$NIX_INSTALLER_NO_CONFIRM"
|
|
||||||
|
|
||||||
if [ "${RUNNER_OS}" == "Linux" ]; then
|
|
||||||
export PLANNER="linux"
|
|
||||||
elif [ "${RUNNER_OS}" == "macOS" ]; then
|
|
||||||
export PLANNER="macos"
|
|
||||||
else
|
|
||||||
echo "${RUNNER_OS} not supported"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl --retry 20 -L $NIX_INSTALLER_URL | sh -s -- install ${PLANNER} ${{ inputs.extra-args }}
|
|
||||||
|
|
||||||
if [ -n "$HTTP_PID" ]; then
|
|
||||||
kill $HTTP_PID
|
|
||||||
fi
|
|
||||||
|
|
3175
dist/index.js
vendored
Normal file
3175
dist/index.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
73
dist/licenses.txt
vendored
Normal file
73
dist/licenses.txt
vendored
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
@actions/core
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/http-client
|
||||||
|
MIT
|
||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
tunnel
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Koichi Kobayashi
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
uuid
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
dist/sourcemap-register.js
vendored
Normal file
1
dist/sourcemap-register.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6079
package-lock.json
generated
Normal file
6079
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
39
package.json
Normal file
39
package.json
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"name": "nix-installer-action",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "You can use [`nix-installer`](https://github.com/DeterminateSystems/nix-installer) as a Github action:",
|
||||||
|
"main": "lib/main.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"format": "prettier --write '**/*.ts'",
|
||||||
|
"lint": "eslint src/**/*.ts",
|
||||||
|
"package": "ncc build --source-map --license licenses.txt",
|
||||||
|
"all": "npm run build && npm run format && npm run lint && npm run package"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/DeterminateSystems/nix-installer-action.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/DeterminateSystems/nix-installer-action/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/DeterminateSystems/nix-installer-action#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.10.0",
|
||||||
|
"@actions/github": "^5.1.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^18.16.3",
|
||||||
|
"@typescript-eslint/parser": "^5.59.2",
|
||||||
|
"@vercel/ncc": "^0.36.1",
|
||||||
|
"eslint": "^8.44.0",
|
||||||
|
"eslint-plugin-github": "^4.3.6",
|
||||||
|
"eslint-plugin-import": "^2.26.0",
|
||||||
|
"eslint-plugin-prettier": "^5.0.0-alpha.1",
|
||||||
|
"prettier": "^3.0.0",
|
||||||
|
"typescript": "^5.1.6"
|
||||||
|
}
|
||||||
|
}
|
360
src/main.ts
Normal file
360
src/main.ts
Normal file
|
@ -0,0 +1,360 @@
|
||||||
|
import * as actions_core from '@actions/core'
|
||||||
|
import {mkdtemp, open} from 'node:fs/promises'
|
||||||
|
import {spawn} from 'node:child_process'
|
||||||
|
import {join} from 'node:path'
|
||||||
|
import {tmpdir} from 'node:os'
|
||||||
|
import {Readable} from 'node:stream'
|
||||||
|
|
||||||
|
class NixInstallerAction {
|
||||||
|
platform: string
|
||||||
|
backtrace: string | null
|
||||||
|
extra_args: string | null
|
||||||
|
extra_conf: string[] | null
|
||||||
|
github_token: string | null
|
||||||
|
// TODO: linux_init
|
||||||
|
init: string | null
|
||||||
|
local_root: string | null
|
||||||
|
log_directives: string | null
|
||||||
|
logger: string | null
|
||||||
|
ssl_cert_file: string | null
|
||||||
|
proxy: string | null
|
||||||
|
mac_case_sensitive: string | null
|
||||||
|
mac_encrypt: string | null
|
||||||
|
mac_root_disk: string | null
|
||||||
|
mac_volume_label: string | null
|
||||||
|
modify_profile: boolean | null
|
||||||
|
nix_build_group_id: number | null
|
||||||
|
nix_build_group_name: string | null
|
||||||
|
nix_build_user_base: number | null
|
||||||
|
nix_build_user_count: number | null
|
||||||
|
nix_build_user_prefix: string | null
|
||||||
|
planner: string | null
|
||||||
|
reinstall: boolean | null
|
||||||
|
start_daemon: boolean | null
|
||||||
|
diagnostic_endpoint: string | null
|
||||||
|
trust_runner_user: boolean | null
|
||||||
|
nix_installer_url: URL
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.platform = get_nix_platform()
|
||||||
|
this.backtrace = action_input_string_or_null('backtrace')
|
||||||
|
this.extra_args = action_input_string_or_null('extra-args')
|
||||||
|
this.extra_conf = action_input_multiline_string_or_null('extra-conf')
|
||||||
|
this.github_token = action_input_string_or_null('github-token')
|
||||||
|
this.init = action_input_string_or_null('init')
|
||||||
|
this.local_root = action_input_string_or_null('local-root')
|
||||||
|
this.log_directives = action_input_string_or_null('log-directives')
|
||||||
|
this.logger = action_input_string_or_null('logger')
|
||||||
|
this.ssl_cert_file = action_input_string_or_null('ssl-cert-file')
|
||||||
|
this.proxy = action_input_string_or_null('proxy')
|
||||||
|
this.mac_case_sensitive = action_input_string_or_null('mac-case-sensitive')
|
||||||
|
this.mac_encrypt = action_input_string_or_null('mac-encrypt')
|
||||||
|
this.mac_root_disk = action_input_string_or_null('mac-root-disk')
|
||||||
|
this.mac_volume_label = action_input_string_or_null('mac-volume-label')
|
||||||
|
this.modify_profile = action_input_bool_or_null('modify-profile')
|
||||||
|
this.nix_build_group_id = action_input_number_or_null('nix-build-group-id')
|
||||||
|
this.nix_build_group_name = action_input_string_or_null(
|
||||||
|
'nix-build-group-name'
|
||||||
|
)
|
||||||
|
this.nix_build_user_base = action_input_number_or_null(
|
||||||
|
'nix_build-user-base'
|
||||||
|
)
|
||||||
|
this.nix_build_user_count = action_input_number_or_null(
|
||||||
|
'nix-build-user-count'
|
||||||
|
)
|
||||||
|
this.nix_build_user_prefix = action_input_string_or_null(
|
||||||
|
'nix-build-user-prefix'
|
||||||
|
)
|
||||||
|
this.planner = action_input_string_or_null('planner')
|
||||||
|
this.reinstall = action_input_bool_or_null('reinstall')
|
||||||
|
this.start_daemon = action_input_bool_or_null('start-daemon')
|
||||||
|
this.diagnostic_endpoint = action_input_string_or_null(
|
||||||
|
'diagnostic-endpoint'
|
||||||
|
)
|
||||||
|
this.trust_runner_user = action_input_bool_or_null('trust-runner-user')
|
||||||
|
this.nix_installer_url = resolve_nix_installer_url(this.platform)
|
||||||
|
}
|
||||||
|
|
||||||
|
private executionEnvironment(): ExecuteEnvironment {
|
||||||
|
const env: ExecuteEnvironment = {}
|
||||||
|
|
||||||
|
if (this.backtrace !== null) {
|
||||||
|
env.RUST_BACKTRACE = this.backtrace
|
||||||
|
}
|
||||||
|
if (this.modify_profile !== null) {
|
||||||
|
if (this.modify_profile) {
|
||||||
|
env.NIX_INSTALLER_MODIFY_PROFILE = '1'
|
||||||
|
} else {
|
||||||
|
env.NIX_INSTALLER_MODIFY_PROFILE = '0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.nix_build_group_id !== null) {
|
||||||
|
env.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nix_build_group_id}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.nix_build_group_name !== null) {
|
||||||
|
env.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = this.nix_build_group_name
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.nix_build_user_prefix !== null) {
|
||||||
|
env.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = this.nix_build_user_prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.nix_build_user_count !== null) {
|
||||||
|
env.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nix_build_user_count}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.nix_build_user_base !== null) {
|
||||||
|
env.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nix_build_user_count}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.nix_installer_url !== null) {
|
||||||
|
env.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nix_installer_url}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.proxy !== null) {
|
||||||
|
env.NIX_INSTALLER_PROXY = this.proxy
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.ssl_cert_file !== null) {
|
||||||
|
env.NIX_INSTALLER_SSL_CERT_FILE = this.ssl_cert_file
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.diagnostic_endpoint !== null) {
|
||||||
|
env.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = this.diagnostic_endpoint
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Error if the user uses these on not-MacOS
|
||||||
|
if (this.mac_encrypt !== null) {
|
||||||
|
env.NIX_INSTALLER_ENCRYPT = this.mac_encrypt
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mac_case_sensitive !== null) {
|
||||||
|
env.NIX_INSTALLER_CASE_SENSITIVE = this.mac_case_sensitive
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mac_volume_label !== null) {
|
||||||
|
env.NIX_INSTALLER_VOLUME_LABEL = this.mac_volume_label
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mac_root_disk !== null) {
|
||||||
|
env.NIX_INSTALLER_ROOT_DISK = this.mac_root_disk
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Error if the user uses these on MacOS
|
||||||
|
if (this.init !== null) {
|
||||||
|
env.NIX_INSTALLER_INIT = this.init
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.start_daemon !== null) {
|
||||||
|
if (this.start_daemon) {
|
||||||
|
env.NIX_INSTALLER_START_DAEMON = '1'
|
||||||
|
} else {
|
||||||
|
env.NIX_INSTALLER_START_DAEMON = '0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return env
|
||||||
|
}
|
||||||
|
|
||||||
|
private async execute(binary_path: string): Promise<number> {
|
||||||
|
const env = this.executionEnvironment()
|
||||||
|
|
||||||
|
const spawned = spawn(`${binary_path} ${this.extra_args}`, {env})
|
||||||
|
|
||||||
|
spawned.stdout.on('data', data => {
|
||||||
|
actions_core.debug(`stdout: ${data}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
spawned.stderr.on('data', data => {
|
||||||
|
actions_core.debug(`stderr: ${data}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
const exit_code: number = await new Promise((resolve, _reject) => {
|
||||||
|
spawned.on('close', resolve)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (exit_code !== 0) {
|
||||||
|
throw new Error(`Non-zero exit code of \`${exit_code}\` detected`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return exit_code
|
||||||
|
}
|
||||||
|
|
||||||
|
async install(): Promise<void> {
|
||||||
|
const binary_path = await this.fetch_binary()
|
||||||
|
await this.execute(binary_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetch_binary(): Promise<string> {
|
||||||
|
if (!this.local_root) {
|
||||||
|
const request = new Request(this.nix_installer_url, {
|
||||||
|
redirect: 'follow'
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await fetch(request)
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(
|
||||||
|
`Got a status of ${response.status} from \`${this.nix_installer_url}\`, expected a 200`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const tempdir = await mkdtemp(join(tmpdir(), 'nix-installer-'))
|
||||||
|
const tempfile = join(tempdir, `nix-installer-${this.platform}`)
|
||||||
|
|
||||||
|
const handle = await open(tempfile)
|
||||||
|
const writer = handle.createWriteStream()
|
||||||
|
|
||||||
|
const blob = await response.blob()
|
||||||
|
const stream = blob.stream() as unknown as Readable
|
||||||
|
stream.pipe(writer)
|
||||||
|
writer.close()
|
||||||
|
|
||||||
|
return tempfile
|
||||||
|
} else {
|
||||||
|
return join(this.local_root, `nix-installer-${this.platform}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExecuteEnvironment = {
|
||||||
|
// All env vars are strings, no fanciness here.
|
||||||
|
RUST_BACKTRACE?: string
|
||||||
|
NIX_INSTALLER_MODIFY_PROFILE?: string
|
||||||
|
NIX_INSTALLER_NIX_BUILD_GROUP_NAME?: string
|
||||||
|
NIX_INSTALLER_NIX_BUILD_GROUP_ID?: string
|
||||||
|
NIX_INSTALLER_NIX_BUILD_USER_PREFIX?: string
|
||||||
|
NIX_INSTALLER_NIX_BUILD_USER_COUNT?: string
|
||||||
|
NIX_INSTALLER_NIX_BUILD_USER_ID_BASE?: string
|
||||||
|
NIX_INSTALLER_NIX_PACKAGE_URL?: string
|
||||||
|
NIX_INSTALLER_PROXY?: string
|
||||||
|
NIX_INSTALLER_SSL_CERT_FILE?: string
|
||||||
|
NIX_INSTALLER_DIAGNOSTIC_ENDPOINT?: string
|
||||||
|
NIX_INSTALLER_ENCRYPT?: string
|
||||||
|
NIX_INSTALLER_CASE_SENSITIVE?: string
|
||||||
|
NIX_INSTALLER_VOLUME_LABEL?: string
|
||||||
|
NIX_INSTALLER_ROOT_DISK?: string
|
||||||
|
NIX_INSTALLER_INIT?: string
|
||||||
|
NIX_INSTALLER_START_DAEMON?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_nix_platform(): string {
|
||||||
|
const env_os = process.env.RUNNER_OS
|
||||||
|
const env_arch = process.env.RUNNER_ARCH
|
||||||
|
|
||||||
|
if (env_os === 'macOS' && env_arch === 'X64') {
|
||||||
|
return 'x86_64-darwin'
|
||||||
|
} else if (env_os === 'macOS' && env_arch === 'ARM64') {
|
||||||
|
return 'aarch64-darwin'
|
||||||
|
} else if (env_os === 'Linux' && env_arch === 'X64') {
|
||||||
|
return 'x86_64-linux'
|
||||||
|
} else if (env_os === 'Linux' && env_arch === 'ARM64') {
|
||||||
|
return 'aarch64-linux'
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`) and \`RUNNER_ARCH\` (currently \`${env_arch}\`) combination`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolve_nix_installer_url(platform: string): URL {
|
||||||
|
// Only one of these are allowed.
|
||||||
|
const nix_installer_branch = action_input_string_or_null(
|
||||||
|
'nix-installer-branch'
|
||||||
|
)
|
||||||
|
const nix_installer_pr = action_input_number_or_null('nix-installer-pr')
|
||||||
|
const nix_installer_revision = action_input_string_or_null(
|
||||||
|
'nix-installer-revision'
|
||||||
|
)
|
||||||
|
const nix_installer_tag = action_input_string_or_null('nix-installer-tag')
|
||||||
|
const nix_installer_url = action_input_string_or_null('nix-installer-url')
|
||||||
|
|
||||||
|
let num_set = 0
|
||||||
|
if (nix_installer_branch !== null) {
|
||||||
|
num_set += 1
|
||||||
|
}
|
||||||
|
if (nix_installer_pr !== null) {
|
||||||
|
num_set += 1
|
||||||
|
}
|
||||||
|
if (nix_installer_revision !== null) {
|
||||||
|
num_set += 1
|
||||||
|
}
|
||||||
|
if (nix_installer_tag !== null) {
|
||||||
|
num_set += 1
|
||||||
|
}
|
||||||
|
if (nix_installer_url !== null) {
|
||||||
|
num_set += 1
|
||||||
|
}
|
||||||
|
if (num_set > 1) {
|
||||||
|
throw new Error(
|
||||||
|
`The following options are mututally exclusive, but ${num_set} were set: \`nix_installer_branch\`, \`nix_installer_pr\`, \`nix_installer_revision\`, \`nix_installer_tag\`, and \`nix_installer_url\``
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nix_installer_branch !== null) {
|
||||||
|
return new URL(
|
||||||
|
`https://install.determinate.systems/nix/branch/${nix_installer_branch}/nix-installer-${platform}?ci=github`
|
||||||
|
)
|
||||||
|
} else if (nix_installer_pr !== null) {
|
||||||
|
return new URL(
|
||||||
|
`https://install.determinate.systems/nix/pr/${nix_installer_pr}/nix-installer-${platform}?ci=github`
|
||||||
|
)
|
||||||
|
} else if (nix_installer_revision !== null) {
|
||||||
|
return new URL(
|
||||||
|
`https://install.determinate.systems/nix/rev/${nix_installer_revision}/nix-installer-${platform}?ci=github`
|
||||||
|
)
|
||||||
|
} else if (nix_installer_tag !== null) {
|
||||||
|
return new URL(
|
||||||
|
`https://install.determinate.systems/nix/tag/${nix_installer_tag}/nix-installer-${platform}?ci=github`
|
||||||
|
)
|
||||||
|
} else if (nix_installer_url !== null) {
|
||||||
|
return new URL(nix_installer_url)
|
||||||
|
} else {
|
||||||
|
return new URL(
|
||||||
|
`https://install.determinate.systems/nix/nix-installer-${platform}?ci=github`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_input_string_or_null(name: string): string | null {
|
||||||
|
const value = actions_core.getInput(name)
|
||||||
|
if (value === '') {
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_input_multiline_string_or_null(name: string): string[] | null {
|
||||||
|
const value = actions_core.getMultilineInput(name)
|
||||||
|
if (value.length === 0) {
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_input_number_or_null(name: string): number | null {
|
||||||
|
const value = actions_core.getInput(name)
|
||||||
|
if (value === '') {
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
return Number(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_input_bool_or_null(name: string): boolean {
|
||||||
|
return actions_core.getBooleanInput(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const installer = new NixInstallerAction()
|
||||||
|
await installer.install()
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error) actions_core.setFailed(error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
|
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||||
|
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"**/*.test.ts"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue