1
0
Fork 0
mirror of https://git.madhouse-project.org/actions/nix.git synced 2024-11-23 20:19:16 +01:00
nix/install/bin/install-nix
Gergely Nagy 704579d3cd Initial import
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
2023-09-22 19:37:47 +02:00

41 lines
819 B
Bash
Executable file

#! /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