mirror of
https://git.madhouse-project.org/actions/nix.git
synced 2025-05-09 21:59:53 +02:00
Initial import
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
commit
704579d3cd
4 changed files with 736 additions and 0 deletions
16
install/action.yml
Normal file
16
install/action.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
name: install-nix
|
||||
author: Gergely Nagy
|
||||
description: "Install the Nix package manager on non-NixOS hosts"
|
||||
inputs:
|
||||
install-url:
|
||||
description: "URL to download the installer from"
|
||||
required: true
|
||||
default: "https://nixos.org/nix/install"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- shell: bash
|
||||
run: $GITHUB_ACTION_PATH/bin/install-nix
|
||||
env:
|
||||
INPUT_INSTALL_URL: ${{ inputs.install-url }}
|
41
install/bin/install-nix
Executable file
41
install/bin/install-nix
Executable file
|
@ -0,0 +1,41 @@
|
|||
#! /usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if type -p nix &>/dev/null; then
|
||||
echo "Nix is already installed."
|
||||
exit
|
||||
fi
|
||||
|
||||
workdir=$(mktemp -d)
|
||||
trap 'rm -rf "$workdir"' EXIT
|
||||
|
||||
preconfigure_nix() {
|
||||
cat >"${workdir}/nix.conf" <<EOF
|
||||
build-users-group =
|
||||
experimental-features = nix-command flakes
|
||||
max-jobs = auto
|
||||
show-trace = true
|
||||
trusted-users = root ${USER:-}
|
||||
EOF
|
||||
|
||||
install -d -m 0755 /nix
|
||||
install -d -m 0755 /etc/nix
|
||||
cp "${workdir}/nix.conf" /etc/nix/nix.conf
|
||||
}
|
||||
|
||||
download_installer() {
|
||||
curl -sS -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}"
|
||||
}
|
||||
|
||||
install_nix() {
|
||||
bash "$workdir/install" --no-daemon --no-channel-add --yes
|
||||
}
|
||||
|
||||
post_install() {
|
||||
echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH"
|
||||
}
|
||||
|
||||
preconfigure_nix
|
||||
download_installer
|
||||
install_nix
|
||||
post_install
|
Loading…
Add table
Add a link
Reference in a new issue