mirror of
https://git.madhouse-project.org/actions/nix.git
synced 2024-11-27 14:09:16 +01:00
704579d3cd
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
41 lines
819 B
Bash
Executable file
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
|