mirror of
https://git.madhouse-project.org/actions/nix.git
synced 2024-11-23 20:19:16 +01:00
42 lines
819 B
Text
42 lines
819 B
Text
|
#! /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
|