077e773ecaf7
make NixOS installer profile-only: drop generate_nixos_module + offer_config_import (no more ~/nina.nix generation or /etc/nixos editing), so curl|sh does a single per-user 'nix profile add' instead of also wiring a system module — fixes the double-install; remove now-dead out/hr helpers and unused GREEN/BOLD palette vars; update the source-build note; document the declarative module + flake-input paths in README for power users (the nixos-module.nix/flake stay in the repo); sh -n clean
- time
- 2026-06-06 01:30 UTC · 4 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- profile-only installer
- parent
- 68fb95c07a2f
↓ nina-077e773e.tar.gzatlas at this save
files changed2 files
README.md+28 −0install.sh+2 −130README.md+28 −0
@@ -19,6 +19,9 @@1919 curl -fsSL kepr.uk/nina/install.sh | sh2020 ```2121 22+On NixOS this installs nina into your **nix profile** — instant, per-user, no23+`sudo`, and it never touches `/etc/nixos`. Remove it any time with `nina goodbye`.24+2225 or clone and build:2326 2427 ```sh@@ -29,6 +32,31 @@2932 3033 **linux · nixos 24.05+** — requires `nix-command` and `flakes` experimental features. 3134 Run `nina setup` on first use to enable them automatically.35+36+### declarative install (power users)37+38+Prefer to manage nina alongside the rest of your system? The repo ships a NixOS39+module, so you can install her the declarative way instead of the profile.40+41+Plain `configuration.nix` — add to your `imports`:42+43+```nix44+imports = [45+ "${builtins.fetchTarball "https://kepr.uk/nina/archive/HEAD.tar.gz"}/nixos-module.nix"46+];47+programs.nina.enable = true;48+```49+50+Flake-based config — add nina as an input:51+52+```nix53+inputs.nina.url = "https://kepr.uk/nina/archive/HEAD.tar.gz";54+# in your nixosModules list: nina.nixosModules.default55+# then set: programs.nina.enable = true;56+```57+58+Then `sudo nixos-rebuild switch`. Pick **one** method — the profile install and59+the declarative module both put `nina` on your PATH, so don't run both.3260 3361 ---3462 install.sh+2 −130
@@ -16,13 +16,11 @@1616 if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then1717 PINK="$(printf '\033[38;2;255;183;197m')"1818 CYAN="$(printf '\033[36m')"19- GREEN="$(printf '\033[32m')"2019 RED="$(printf '\033[31m')"2120 DIM="$(printf '\033[2m')"22- BOLD="$(printf '\033[1m')"2321 RESET="$(printf '\033[0m')"2422 else25- PINK=""; CYAN=""; GREEN=""; RED=""; DIM=""; BOLD=""; RESET=""23+ PINK=""; CYAN=""; RED=""; DIM=""; RESET=""2624 fi2725 2826 os="$(uname -s)"@@ -43,11 +41,6 @@4341 blank() { printf '\n'; }4442 is_nixos() { [ -e /etc/NIXOS ]; }4543 46-# Unprefixed output for the closing sections, where the "nina:" stutter on47-# every line hurts readability. `out` indents body text; `hr` draws a divider.48-out() { printf ' %s\n' "$1"; }49-hr() { printf ' %s────────────────────────────────────────────────%s\n' "$DIM" "$RESET"; }50-5144 fetch_text() {5245 if have curl; then curl -fsSL "$1"5346 elif have wget; then wget -qO- "$1"@@ -203,128 +196,9 @@203196 chmod +x "${INSTALL_DIR}/nina"204197 blank205198 say "installed from source → ${INSTALL_DIR}/nina"206- say "note: binary built outside nix — adopt ~/nina.nix into configuration.nix"207- say " to make nina fully nix-managed (nina goodbye handles removal either way)"199+ say "note: per-user binary, not nix-managed (nina goodbye removes it cleanly)"208200 }209201 210-# ── generate ~/nina.nix ───────────────────────────────────────────────────────211-212-# Offer to wire ~/nina.nix into /etc/nixos/configuration.nix. Returns 0 when the213-# import is in place (added now, or already present), 1 when the caller should214-# fall back to printing manual instructions. Conservative by design: only edits215-# an existing `imports = [ … ]` list, always backs the file up first, and never216-# touches anything without an explicit yes from the terminal.217-offer_config_import() {218- config="$1"219- nina_nix="$2"220-221- [ -f "$config" ] && [ -r "$config" ] || return 1222-223- # Already wired up — just remind how to apply it.224- if grep -qF "$nina_nix" "$config" 2>/dev/null; then225- out "already imported in ${CYAN}${config}${RESET}"226- out "apply with ${BOLD}sudo nixos-rebuild switch${RESET}"227- blank228- return 0229- fi230-231- # Need an existing imports list to extend; guessing where else to put it232- # risks producing a config that won't evaluate.233- grep -qE '^[[:space:]]*imports[[:space:]]*=[[:space:]]*\[' "$config" || return 1234-235- # Read the answer from the terminal so it works under `curl … | sh`.236- [ -r /dev/tty ] || return 1237- printf ' add it to %s%s%s now? %s[y/N]%s ' "$CYAN" "$config" "$RESET" "$DIM" "$RESET" > /dev/tty238- IFS= read -r ans < /dev/tty 2>/dev/null || ans=""239- case "$ans" in240- [Yy]*) ;;241- *) return 1 ;;242- esac243-244- ts="$(date +%Y%m%d%H%M%S 2>/dev/null || echo backup)"245- backup="${config}.nina-bak.${ts}"246- sudo cp "$config" "$backup" 2>/dev/null \247- || { blank; out "could not back up ${config} — add it manually instead."; blank; return 1; }248-249- # Insert our path as the first entry of the first imports list.250- tmp="$(mktemp /tmp/nina-conf.XXXXXX)"251- awk -v p="$nina_nix" '252- !done && /imports[[:space:]]*=[[:space:]]*\[/ { sub(/\[/, "[ " p); done=1 }253- { print }254- ' "$config" > "$tmp" 2>/dev/null255-256- if ! sudo cp "$tmp" "$config" 2>/dev/null; then257- rm -f "$tmp"258- blank259- out "could not write ${config}."260- out "restore the backup with: sudo cp ${backup} ${config}"261- blank262- return 1263- fi264- rm -f "$tmp"265-266- blank267- out "${GREEN}✓${RESET} added the import to ${CYAN}${config}${RESET}"268- out " ${DIM}backup kept at ${backup}${RESET}"269- out " apply with ${BOLD}sudo nixos-rebuild switch${RESET}"270- blank271- return 0272-}273-274-generate_nixos_module() {275- # Write ~/nina.nix without invoking shell substitution on the nix code inside.276- cat > "$HOME/nina.nix" <<'NIXEOF'277-# ~/nina.nix — generated by the nina installer278-#279-# Declares nina as a NixOS system package.280-#281-# Add to /etc/nixos/configuration.nix:282-# imports = [ /home/YOUR_USER/nina.nix ];283-# Then: sudo nixos-rebuild switch284-#285-# To update: nina update (or re-run the installer)286-# To remove: nina goodbye (or delete this file, then nixos-rebuild switch)287-#288-# For flake-based configurations, add nina as a flake input instead:289-# inputs.nina.url = "https://kepr.uk/nina/archive/HEAD.tar.gz";290-# # in your nixosModules list: nina.nixosModules.default291-# # then set: programs.nina.enable = true;292-{ ... }:293-{294- imports = [295- "${builtins.fetchTarball "https://kepr.uk/nina/archive/HEAD.tar.gz"}/nixos-module.nix"296- ];297- programs.nina.enable = true;298-}299-NIXEOF300-301- nina_nix="$HOME/nina.nix"302-303- blank304- hr305- out "${BOLD}system-wide install${RESET} ${DIM}(optional)${RESET}"306- hr307- blank308- out "nina is installed for your user. To manage her alongside the"309- out "rest of your system, a module was written to:"310- blank311- out " ${CYAN}${nina_nix}${RESET}"312- blank313-314- if offer_config_import "/etc/nixos/configuration.nix" "$nina_nix"; then315- return 0316- fi317-318- blank319- out "to do it yourself, add this to the ${CYAN}imports${RESET} list in"320- out "${CYAN}/etc/nixos/configuration.nix${RESET}:"321- blank322- out " ${CYAN}${nina_nix}${RESET}"323- blank324- out "then run ${BOLD}sudo nixos-rebuild switch${RESET}"325- blank326-}327-328202 # ── Zig version check ─────────────────────────────────────────────────────────329203 330204 check_zig() {@@ -447,7 +321,6 @@447321 if is_nixos; then448322 say "NixOS detected"449323 if nixos_profile_install; then450- generate_nixos_module451324 maybe_setup_features452325 farewell453326 exit 0@@ -463,7 +336,6 @@463336 fi464337 say "no prebuilt binary available — building from source"465338 nixos_shell_build466- generate_nixos_module467339 check_path468340 maybe_setup_features469341 farewell