feat: add installer to live ISO; skip nix pkgs if <4GB free in /nix

- iso/build-live-iso.sh: copy install.sh+lib/ to /usr/local/lib/void-installer/,
  config+profiles to /usr/local/share/installer/, bake secrets.env as
  /etc/installer-secrets.env, add 'Install Void Linux' .desktop launcher
  (opens alacritty+sudo), create /usr/local/bin/void-install wrapper
- installer/first-login.sh: skip nix profile add when /nix has <4GB free
  (live tmpfs overlay fills up with ~3-4GB of nix packages); packages are
  installed on first login after the system is installed instead
This commit is contained in:
mozempk
2026-04-23 09:32:39 +02:00
parent 0f49e9aafa
commit 30ae82c5fd
2 changed files with 87 additions and 27 deletions

View File

@@ -35,41 +35,51 @@ fi
# --- Nix user packages (google-chrome, spotify, discord, etc.) ---
# Present when running from the live ISO (written by build-live-iso.sh).
# In the installed system the packages come from first-boot-nix.sh instead.
# NOTE: nix packages are intentionally skipped in the live session — they
# can total 3-4 GB which exceeds the tmpfs overlay on typical hardware.
# They will be installed on the first login after the system is installed.
NIX_PACKAGES_FILE="${NIX_PACKAGES_FILE:-/usr/local/libexec/nix-packages.list}"
if [[ -r "$NIX_PACKAGES_FILE" ]] && command -v nix >/dev/null 2>&1; then
echo "==> installing nix user packages from $NIX_PACKAGES_FILE"
remaining=$(df -k /nix 2>/dev/null | awk 'NR==2{print $4}')
# Require at least 4GB free in /nix before attempting package install
if [[ -n "$remaining" && "$remaining" -lt 4194304 ]]; then
echo "==> skipping nix packages in live session (only ${remaining}KB free in /nix)"
echo " packages will be installed on first login after installation"
else
echo "==> installing nix user packages from $NIX_PACKAGES_FILE"
# Source nix profile.d scripts so PATH and env are set.
for f in /etc/profile.d/nix*.sh; do
# shellcheck disable=SC1090
[[ -r "$f" ]] && . "$f"
done
# Source nix profile.d scripts so PATH and env are set.
for f in /etc/profile.d/nix*.sh; do
# shellcheck disable=SC1090
[[ -r "$f" ]] && . "$f"
done
# Guard: nix-env --switch-profile creates a circular symlink when given
# ~/.nix-profile as the target (it points to itself). Remove it so
# 'nix profile add' can initialise a clean profile.
if [[ -L "$HOME/.nix-profile" ]]; then
_target=$(readlink "$HOME/.nix-profile")
if [[ "$_target" == ".nix-profile" || "$_target" == "$HOME/.nix-profile" ]]; then
echo " removing circular .nix-profile symlink"
rm -f "$HOME/.nix-profile"
# Guard: nix-env --switch-profile creates a circular symlink when given
# ~/.nix-profile as the target (it points to itself). Remove it so
# 'nix profile add' can initialise a clean profile.
if [[ -L "$HOME/.nix-profile" ]]; then
_target=$(readlink "$HOME/.nix-profile")
if [[ "$_target" == ".nix-profile" || "$_target" == "$HOME/.nix-profile" ]]; then
echo " removing circular .nix-profile symlink"
rm -f "$HOME/.nix-profile"
fi
unset _target
fi
unset _target
fi
# D-Bus session is available when autostarted from Cinnamon.
if [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]]; then
eval "$(dbus-launch --sh-syntax 2>/dev/null)" || true
fi
# D-Bus session is available when autostarted from Cinnamon.
if [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]]; then
eval "$(dbus-launch --sh-syntax 2>/dev/null)" || true
fi
export NIXPKGS_ALLOW_UNFREE=1
export NIXPKGS_ALLOW_UNFREE=1
mapfile -t pkgs < <(grep -vE '^\s*(#|$)' "$NIX_PACKAGES_FILE")
if [[ ${#pkgs[@]} -gt 0 ]]; then
echo " packages: ${pkgs[*]}"
# 'nix profile install' is deprecated as of nix 2.x — use 'nix profile add'
nix profile add --impure "${pkgs[@]}" 2>&1 || {
echo "!! nix profile add failed (partial install may have succeeded)"; }
mapfile -t pkgs < <(grep -vE '^\s*(#|$)' "$NIX_PACKAGES_FILE")
if [[ ${#pkgs[@]} -gt 0 ]]; then
echo " packages: ${pkgs[*]}"
# 'nix profile install' is deprecated as of nix 2.x — use 'nix profile add'
nix profile add --impure "${pkgs[@]}" 2>&1 || {
echo "!! nix profile add failed (partial install may have succeeded)"; }
fi
fi
fi