#!/usr/bin/env bash # Install or uninstall Nix + Home Manager on SteamOS (Steam Frame, Steam Deck), # and clean up what steam-frame-nix wrote outside the Nix store. # # curl -fsSL https://steam-frame-nix.lhns.de | bash -s -- install # curl -fsSL https://steam-frame-nix.lhns.de | bash -s -- uninstall # curl -fsSL https://steam-frame-nix.lhns.de | bash -s -- cleanup --all # # Run `install.sh --help` for details. Works from a file or piped into bash # (prompts read from /dev/tty). set -euo pipefail TEMPLATE="${STEAM_FRAME_NIX_TEMPLATE:-github:lhns/steam-frame-nix}" NIX_INSTALLER_URL="${NIX_INSTALLER_URL:-https://artifacts.nixos.org/nix-installer}" HM_FLAKE="${HM_FLAKE:-home-manager/master}" NIX_PROFILE_SCRIPT=/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh NIX_RECEIPT=/nix/receipt.json NIX_INSTALLER_BIN=/nix/nix-installer CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" HM_CONFIG_LINK="$CONFIG_HOME/home-manager" DEFAULT_CONFIG_DIR="$HOME/nix-config" USER_NIX_CONF="$CONFIG_HOME/nix/nix.conf" USER_UNIT_DIR="$CONFIG_HOME/systemd/user" USER_NAME="$(id -un)" USER_ID="$(id -u)" OUTER_RUNTIME_DIR="${STEAM_FRAME_NIX_RUNTIME_DIR:-/run/user/$USER_ID}" SFN_PROC="${STEAM_FRAME_NIX_PROC:-/proc}" # tests: a fake /proc SFN_TTY="${STEAM_FRAME_NIX_TTY:-/dev/tty}" # tests: a file # uninstall_nix: nix.mount detaches lazily (tests: another directory) NIX_MOUNT_DROPIN="${STEAM_FRAME_NIX_SYSTEM_RUNTIME:-/run/systemd/system}/nix.mount.d/50-steam-frame-nix-lazy-unmount.conf" ASSUME_YES=0 RO_RELOCK=0 CLONE_TMP='' # an unfinished --clone, removed on exit NIX_DROPIN=0 # NIX_MOUNT_DROPIN written, removed on exit # --- output ----------------------------------------------------------------- if [[ -t 1 ]]; then B=$'\e[1m' G=$'\e[1;32m' Y=$'\e[1;33m' R=$'\e[1;31m' N=$'\e[0m' else B='' G='' Y='' R='' N=''; fi step() { printf '%s==>%s %s%s%s\n' "$G" "$N" "$B" "$*" "$N"; } info() { printf ' %s\n' "$*"; } warn() { printf '%swarning:%s %s\n' "$Y" "$N" "$*" >&2; } die() { printf '%serror:%s %s\n' "$R" "$N" "$*" >&2; exit 1; } usage() { cat < [options] Commands: install [--flake | --clone [--dir ] [--ref ]] [--yes] Install Nix (NixOS nix-installer, steam-deck planner, flakes enabled) if it is missing, then activate a Home Manager configuration: --flake given that flake (a directory or a flake reference) --clone given your config's git repository (git@host:owner/repo, https://..., github:owner/repo), cloned into --dir (default ~/nix-config) on branch --ref (anything there but the unchanged template is used as it is), then used like --flake . Private repositories: see the README otherwise ~/.config/home-manager; without it the flake in ~/nix-config, else a new config there from the steam-frame-nix template (either linked to ~/.config/home-manager) Existing dotfiles that conflict are renamed to *.hm-backup-