Files
Multiplane/scripts/nix_bootstrap.sh

39 lines
1.2 KiB
Bash

#!/bin/bash
set -e
echo "Installing Nix package manager..."
# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo "Warning: Running as root. Multi-user installation recommended for non-root users."
fi
# Install xz-utils if not present (required for decompressing Nix tarball)
if ! command -v xz &> /dev/null; then
echo "Installing xz-utils..."
if command -v apt-get &> /dev/null; then
sudo apt-get update && sudo apt-get install -y xz-utils
elif command -v dnf &> /dev/null; then
sudo dnf install -y xz
elif command -v yum &> /dev/null; then
sudo yum install -y xz
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm xz
else
echo "Please install xz-utils manually for your distribution"
exit 1
fi
fi
# Download and run the Nix installer (multi-user mode with daemon)
curl -L https://nixos.org/nix/install | sh -s -- --daemon
# Source Nix profile
if [ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
fi
echo "Nix installation complete!"
echo "Restart your shell or run: source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"