feat(cli): nomarchy-pull / nomarchy-rebuild / nomarchy-home
Some checks failed
Check / eval (push) Has been cancelled
Some checks failed
Check / eval (push) Has been cancelled
Split lifecycle into three clear commands (user pick): nomarchy-pull git pull (if checkout) + flake.lock update nomarchy-rebuild system switch on current lock (snap + nvd) nomarchy-home Home Manager switch Full upgrade: pull && rebuild && home. Legacy sys-update / sys-rebuild / home-update remain as wrappers. nixos-rebuild-snap uses NOMARCHY_PATH. V0: flake check --no-build green.
This commit is contained in:
45
README.md
45
README.md
@@ -182,22 +182,29 @@ home-manager switch --flake .#me # desktop: every theme change, no
|
|||||||
Day-to-day you'll use the shipped shortcuts instead:
|
Day-to-day you'll use the shipped shortcuts instead:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sys-update # nix flake update + system rebuild (BTRFS snapshot first when available)
|
nomarchy-pull # git pull (if checkout) + nix flake update — no rebuild
|
||||||
sys-rebuild # system rebuild against the CURRENT lock (config changes only, no update)
|
nomarchy-rebuild # system rebuild against the CURRENT lock (sudo inside;
|
||||||
# …both end with a package-level diff of what the rebuild changed (nvd)
|
# BTRFS snapshot first when snapper is on; nvd diff after)
|
||||||
home-update # home-manager switch (no flake update, no sudo)
|
nomarchy-home # home-manager switch — desktop only, no sudo, no lock bump
|
||||||
```
|
```
|
||||||
|
|
||||||
**Order matters when pulling distro updates.** `home-update` does *not*
|
| When | Run |
|
||||||
touch the lock — it rebuilds the desktop against the **current**
|
|---|---|
|
||||||
`flake.lock`. A new Nomarchy revision (new keybinds, theming, modules)
|
| Pull newer Nomarchy / nixpkgs / inputs | `nomarchy-pull` |
|
||||||
arrives only when the lock is updated, which `sys-update` does
|
| You changed `system.nix` (or after pull) | `nomarchy-rebuild` |
|
||||||
(`nix flake update`). So to pull an update that affects the desktop layer:
|
| You changed `home.nix` / theme / desktop | `nomarchy-home` |
|
||||||
run `sys-update` **first** (updates the lock + rebuilds the system), **then**
|
| Full upgrade (inputs + both layers) | `nomarchy-pull && nomarchy-rebuild && nomarchy-home` |
|
||||||
`home-update` (re-applies the desktop against the new lock). Doing them in
|
|
||||||
the other order rebuilds the desktop against the *old* inputs and silently
|
**Order matters for distro updates.** `nomarchy-home` rebuilds against the
|
||||||
skips the new home-side changes. After a home-side keybind/config change,
|
**current** `flake.lock` — it never updates inputs. A new Nomarchy revision
|
||||||
also `hyprctl reload` (or relogin) so the running session re-reads it.
|
lands only when the lock is updated (`nomarchy-pull`). So for an upstream
|
||||||
|
desktop change: **pull → rebuild → home**. Home before pull rebuilds against
|
||||||
|
the old inputs and silently skips new home-side changes. After a home-side
|
||||||
|
keybind/config change, also `hyprctl reload` (or relogin) so the session
|
||||||
|
re-reads it.
|
||||||
|
|
||||||
|
Legacy aliases still work: `sys-update` → pull+rebuild, `sys-rebuild` →
|
||||||
|
`nomarchy-rebuild`, `home-update` → `nomarchy-home`.
|
||||||
|
|
||||||
Override anything via the `nomarchy.*` surface or plain NixOS/HM options:
|
Override anything via the `nomarchy.*` surface or plain NixOS/HM options:
|
||||||
appearance (gaps/colors/fonts) changes through `nomarchy-theme-sync`,
|
appearance (gaps/colors/fonts) changes through `nomarchy-theme-sync`,
|
||||||
@@ -397,9 +404,9 @@ nomarchy-theme-sync set ui.gapsOut 16 # tweak one knob (also a switch)
|
|||||||
nomarchy-theme-sync bg next # cycle wallpapers — instant, no rebuild
|
nomarchy-theme-sync bg next # cycle wallpapers — instant, no rebuild
|
||||||
nomarchy-theme-sync bg auto # back to the theme's default wallpaper
|
nomarchy-theme-sync bg auto # back to the theme's default wallpaper
|
||||||
nomarchy-theme-sync get colors.accent
|
nomarchy-theme-sync get colors.accent
|
||||||
sys-update # update inputs + rebuild the system (snapshots first)
|
nomarchy-pull # git pull + flake input update (no rebuild)
|
||||||
sys-rebuild # rebuild the system, current lock (no update)
|
nomarchy-rebuild # rebuild the system, current lock
|
||||||
home-update # rebuild just the desktop layer
|
nomarchy-home # rebuild just the desktop layer
|
||||||
nomarchy-doctor # read-only health sheet (also: menu › System › Doctor)
|
nomarchy-doctor # read-only health sheet (also: menu › System › Doctor)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -429,9 +436,9 @@ gd gds # diff · diff --staged
|
|||||||
gl glg # log graph (last 20 · all branches)
|
gl glg # log graph (last 20 · all branches)
|
||||||
gp gpl gf # push · pull · fetch --all --prune
|
gp gpl gf # push · pull · fetch --all --prune
|
||||||
|
|
||||||
# nix (system/home rebuilds keep their full sys-update / home-update names)
|
# nix (lifecycle: nomarchy-pull / nomarchy-rebuild / nomarchy-home — full names)
|
||||||
ns nr # nix shell · nix run (e.g. ns nixpkgs#ripgrep)
|
ns nr # nix shell · nix run (e.g. ns nixpkgs#ripgrep)
|
||||||
nfu nfc # nix flake update · check
|
nfu nfc # nix flake update · check (prefer nomarchy-pull for day-to-day)
|
||||||
nsearch ngc # nix search nixpkgs · nix-collect-garbage -d
|
nsearch ngc # nix search nixpkgs · nix-collect-garbage -d
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
|
|||||||
@@ -124,8 +124,9 @@ iteration would otherwise rediscover.
|
|||||||
- GTK4/libadwaita/Qt6 read light/dark from the portal's
|
- GTK4/libadwaita/Qt6 read light/dark from the portal's
|
||||||
`org.freedesktop.appearance color-scheme` (dconf), not Stylix polarity
|
`org.freedesktop.appearance color-scheme` (dconf), not Stylix polarity
|
||||||
(§ GTK/Qt ignore the theme's mode).
|
(§ GTK/Qt ignore the theme's mode).
|
||||||
- Update order matters downstream: `sys-update` (lock) before
|
- Update order matters downstream: `nomarchy-pull` (lock) then
|
||||||
`home-update`, or desktop changes are silently skipped against the old
|
`nomarchy-rebuild` then `nomarchy-home`, or desktop changes are silently
|
||||||
|
skipped against the old
|
||||||
lock (README § 3).
|
lock (README § 3).
|
||||||
- Hyprland 0.53 rewrote window rules: `windowrulev2` is a hard error and
|
- Hyprland 0.53 rewrote window rules: `windowrulev2` is a hard error and
|
||||||
the old rule-first `float, class:^…$` no longer parses — both surface a
|
the old rule-first `float, class:^…$` no longer parses — both surface a
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ recent desktop generations — pick one and it activates.
|
|||||||
Or simply apply a theme you know is good: `nomarchy-theme-sync apply
|
Or simply apply a theme you know is good: `nomarchy-theme-sync apply
|
||||||
boreal` (or any preset). If a switch failed halfway, the state file is written
|
boreal` (or any preset). If a switch failed halfway, the state file is written
|
||||||
*before* the rebuild — fix the cause and re-run
|
*before* the rebuild — fix the cause and re-run
|
||||||
`home-manager switch --flake ~/.nomarchy` (or `home-update`).
|
`home-manager switch --flake ~/.nomarchy` (or `nomarchy-home`).
|
||||||
|
|
||||||
Your flake checkout is a git repo, and with auto-commit enabled every
|
Your flake checkout is a git repo, and with auto-commit enabled every
|
||||||
apply is a commit: `git -C ~/.nomarchy log` to see what changed,
|
apply is a commit: `git -C ~/.nomarchy log` to see what changed,
|
||||||
`git revert` the culprit, then `home-update`.
|
`git revert` the culprit, then `nomarchy-home`.
|
||||||
|
|
||||||
## 2. The desktop won't start at all
|
## 2. The desktop won't start at all
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ last 10 generations are kept). That boots yesterday's system unchanged.
|
|||||||
Booting an old generation is temporary — the default entry is still the
|
Booting an old generation is temporary — the default entry is still the
|
||||||
broken one. Make the fix stick from the working boot: revert the change
|
broken one. Make the fix stick from the working boot: revert the change
|
||||||
in `~/.nomarchy` (`git -C ~/.nomarchy revert …` or edit `system.nix`
|
in `~/.nomarchy` (`git -C ~/.nomarchy revert …` or edit `system.nix`
|
||||||
back), then `sys-rebuild`.
|
back), then `nomarchy-rebuild`.
|
||||||
|
|
||||||
## 4. Files went missing or wrong — snapshots (BTRFS installs)
|
## 4. Files went missing or wrong — snapshots (BTRFS installs)
|
||||||
|
|
||||||
|
|||||||
@@ -264,9 +264,9 @@ Design/decision records and a running log of shipped work (items marked
|
|||||||
`gl`/`glg`, `gp`/`gpl`, `gf`), and a nix block (`ns`, `nr`, `nfu`, `nfc`,
|
`gl`/`glg`, `gp`/`gpl`, `gf`), and a nix block (`ns`, `nr`, `nfu`, `nfc`,
|
||||||
`nsearch`, `ngc`), plus `path` and `reload`. Scope decision: short where it
|
`nsearch`, `ngc`), plus `path` and `reload`. Scope decision: short where it
|
||||||
helps but **never shadow a real binary** (same rule as rg/fd — the git block
|
helps but **never shadow a real binary** (same rule as rg/fd — the git block
|
||||||
deliberately avoids `gs`/ghostscript); system/home rebuilds keep their full
|
deliberately avoids `gs`/ghostscript); lifecycle is `nomarchy-pull` /
|
||||||
`sys-update`/`home-update` names rather than getting cryptic aliases. The set
|
`nomarchy-rebuild` / `nomarchy-home` (full names on PATH, not aliases). The
|
||||||
is documented in README §5 (Day-to-day), and `alias` lists them in-shell.
|
set is documented in README §5 (Day-to-day), and `alias` lists shell shortcuts.
|
||||||
- **Theme-switch feedback:** ✓ the "rebuilding…" notification is now
|
- **Theme-switch feedback:** ✓ the "rebuilding…" notification is now
|
||||||
persistent (timeout 0) and replaced in place by "applied ✓" / failure
|
persistent (timeout 0) and replaced in place by "applied ✓" / failure
|
||||||
via a synchronous tag, so a multi-minute switch never reads as a failed
|
via a synchronous tag, so a multi-minute switch never reads as a failed
|
||||||
|
|||||||
@@ -223,8 +223,8 @@ in
|
|||||||
compares the flake's locked inputs (nixpkgs, the Nomarchy input, …)
|
compares the flake's locked inputs (nixpkgs, the Nomarchy input, …)
|
||||||
against upstream and — when Flatpak is enabled — counts Flatpak
|
against upstream and — when Flatpak is enabled — counts Flatpak
|
||||||
updates, surfacing a Waybar indicator + a notification when something
|
updates, surfacing a Waybar indicator + a notification when something
|
||||||
is available. It never changes anything; you still run sys-update /
|
is available. It never changes anything; you still run nomarchy-pull /
|
||||||
home-update / flatpak update yourself'' // { default = config.nomarchy.settings.updates.enable or false; };
|
nomarchy-rebuild / nomarchy-home / flatpak update yourself'' // { default = config.nomarchy.settings.updates.enable or false; };
|
||||||
|
|
||||||
interval = lib.mkOption {
|
interval = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
|||||||
@@ -798,7 +798,7 @@ ${themeRows}
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
nomarchy-theme-sync --quiet set settings.fingerprint.pam "$new" --no-switch
|
nomarchy-theme-sync --quiet set settings.fingerprint.pam "$new" --no-switch
|
||||||
notify-send "Fingerprint" "Use for login: $new — applies on next sys-rebuild."
|
notify-send "Fingerprint" "Use for login: $new — applies on next nomarchy-rebuild."
|
||||||
;;
|
;;
|
||||||
esac ;;
|
esac ;;
|
||||||
|
|
||||||
@@ -843,7 +843,7 @@ ${themeRows}
|
|||||||
printf 'Enter to close.'; read -r _" ;;
|
printf 'Enter to close.'; read -r _" ;;
|
||||||
*Snapshots*) exec "$0" snapshot ;;
|
*Snapshots*) exec "$0" snapshot ;;
|
||||||
*"older generation"*)
|
*"older generation"*)
|
||||||
notify-send "System rollback" "Reboot and pick an older NixOS generation in the boot menu (the last 10 are kept). Make it stick: revert the change in ~/.nomarchy, then sys-rebuild. Details: docs/RECOVERY.md §3." ;;
|
notify-send "System rollback" "Reboot and pick an older NixOS generation in the boot menu (the last 10 are kept). Make it stick: revert the change in ~/.nomarchy, then nomarchy-rebuild. Details: docs/RECOVERY.md §3." ;;
|
||||||
esac ;;
|
esac ;;
|
||||||
|
|
||||||
tools)
|
tools)
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ in
|
|||||||
gpl = "git pull";
|
gpl = "git pull";
|
||||||
gf = "git fetch --all --prune";
|
gf = "git fetch --all --prune";
|
||||||
|
|
||||||
# Nix — the flake/store verbs (system/home rebuilds already have the
|
# Nix — store/flake verbs. Lifecycle is nomarchy-pull /
|
||||||
# sys-update / home-update commands, so they're not re-aliased here).
|
# nomarchy-rebuild / nomarchy-home (full names on PATH, not aliases).
|
||||||
ns = "nix shell"; # ns nixpkgs#ripgrep
|
ns = "nix shell"; # ns nixpkgs#ripgrep
|
||||||
nr = "nix run"; # nr nixpkgs#cowsay
|
nr = "nix run"; # nr nixpkgs#cowsay
|
||||||
nfu = "nix flake update";
|
nfu = "nix flake update"; # prefer nomarchy-pull day-to-day
|
||||||
nfc = "nix flake check";
|
nfc = "nix flake check";
|
||||||
nsearch = "nix search nixpkgs";
|
nsearch = "nix search nixpkgs";
|
||||||
ngc = "nix-collect-garbage -d"; # user generations; sudo for system roots
|
ngc = "nix-collect-garbage -d"; # user generations; sudo for system roots
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Update awareness (opt-in, nomarchy.updates.enable) — a passive background
|
# Update awareness (opt-in, nomarchy.updates.enable) — a passive background
|
||||||
# check that surfaces a Waybar indicator + a notification when updates are
|
# check that surfaces a Waybar indicator + a notification when updates are
|
||||||
# available, without ever changing anything (you still run sys-update /
|
# available, without ever changing anything (you still run nomarchy-pull /
|
||||||
# home-update / flatpak update). It counts:
|
# nomarchy-rebuild / nomarchy-home / flatpak update). It counts:
|
||||||
# • flake inputs whose locked rev is behind upstream (nixpkgs, the Nomarchy
|
# • flake inputs whose locked rev is behind upstream (nixpkgs, the Nomarchy
|
||||||
# input, home-manager …) — via `git ls-remote` on each branch-tracking
|
# input, home-manager …) — via `git ls-remote` on each branch-tracking
|
||||||
# github/git input in flake.lock; offline → skipped, never a false alarm.
|
# github/git input in flake.lock; offline → skipped, never a false alarm.
|
||||||
@@ -83,7 +83,7 @@ let
|
|||||||
msg="$nix flake input(s)"
|
msg="$nix flake input(s)"
|
||||||
[ "$fp" -gt 0 ] && msg="$msg · $fp Flatpak(s)"
|
[ "$fp" -gt 0 ] && msg="$msg · $fp Flatpak(s)"
|
||||||
${pkgs.libnotify}/bin/notify-send -a Nomarchy "Updates available" \
|
${pkgs.libnotify}/bin/notify-send -a Nomarchy "Updates available" \
|
||||||
"$msg — click the bar icon, or run sys-update."
|
"$msg — click the bar icon, or: nomarchy-pull && nomarchy-rebuild && nomarchy-home"
|
||||||
fi
|
fi
|
||||||
refresh_bar ;;
|
refresh_bar ;;
|
||||||
status)
|
status)
|
||||||
@@ -91,7 +91,7 @@ let
|
|||||||
[ "$total" -gt 0 ] 2>/dev/null || exit 0 # up to date / unchecked → hide
|
[ "$total" -gt 0 ] 2>/dev/null || exit 0 # up to date / unchecked → hide
|
||||||
nix=$("$JQ" -r '.nix // 0' "$state"); fp=$("$JQ" -r '.flatpak // 0' "$state")
|
nix=$("$JQ" -r '.nix // 0' "$state"); fp=$("$JQ" -r '.flatpak // 0' "$state")
|
||||||
tip="Updates available"
|
tip="Updates available"
|
||||||
[ "$nix" -gt 0 ] && tip="$tip\n• $nix flake input(s) — sys-update"
|
[ "$nix" -gt 0 ] && tip="$tip\n• $nix flake input(s) — nomarchy-pull && nomarchy-rebuild && nomarchy-home"
|
||||||
[ "$fp" -gt 0 ] && tip="$tip\n• $fp Flatpak(s) — flatpak update"
|
[ "$fp" -gt 0 ] && tip="$tip\n• $fp Flatpak(s) — flatpak update"
|
||||||
printf '{"text":" %d","tooltip":"%s","class":"available"}\n' "$total" "$tip" ;;
|
printf '{"text":" %d","tooltip":"%s","class":"available"}\n' "$total" "$tip" ;;
|
||||||
upgrade)
|
upgrade)
|
||||||
@@ -99,9 +99,13 @@ let
|
|||||||
nix=$("$JQ" -r '.nix // 0' "$state" 2>/dev/null || echo 0)
|
nix=$("$JQ" -r '.nix // 0' "$state" 2>/dev/null || echo 0)
|
||||||
fp=$("$JQ" -r '.flatpak // 0' "$state" 2>/dev/null || echo 0)
|
fp=$("$JQ" -r '.flatpak // 0' "$state" 2>/dev/null || echo 0)
|
||||||
echo "Pending: $nix flake input(s), $fp Flatpak(s)."
|
echo "Pending: $nix flake input(s), $fp Flatpak(s)."
|
||||||
if [ "$nix" -gt 0 ] && command -v sys-update >/dev/null 2>&1; then
|
if [ "$nix" -gt 0 ] && command -v nomarchy-pull >/dev/null 2>&1; then
|
||||||
read -rp "Run sys-update (flake update + system rebuild)? [y/N] " a
|
read -rp "Run nomarchy-pull && nomarchy-rebuild && nomarchy-home? [y/N] " a
|
||||||
[ "$a" = y ] && sys-update
|
if [ "$a" = y ]; then
|
||||||
|
nomarchy-pull
|
||||||
|
nomarchy-rebuild
|
||||||
|
command -v nomarchy-home >/dev/null 2>&1 && nomarchy-home
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$fp" -gt 0 ] && command -v flatpak >/dev/null 2>&1; then
|
if [ "$fp" -gt 0 ] && command -v flatpak >/dev/null 2>&1; then
|
||||||
read -rp "Run flatpak update? [y/N] " a
|
read -rp "Run flatpak update? [y/N] " a
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ in
|
|||||||
|
|
||||||
${distroName} — a NixOS desktop, themed from one JSON.
|
${distroName} — a NixOS desktop, themed from one JSON.
|
||||||
|
|
||||||
sys-update update inputs + rebuild the system
|
nomarchy-pull git pull + flake input update (no rebuild)
|
||||||
sys-rebuild rebuild the system, no input update
|
nomarchy-rebuild rebuild the system (current lock)
|
||||||
home-update apply home/theme changes (no sudo)
|
nomarchy-home rebuild the desktop / Home Manager
|
||||||
nomarchy-theme-sync apply <theme> switch the whole palette
|
nomarchy-theme-sync apply <theme> switch the whole palette
|
||||||
nomarchy-doctor read-only health check
|
nomarchy-doctor read-only health check
|
||||||
SUPER+? keybindings cheatsheet
|
SUPER+? keybindings cheatsheet
|
||||||
@@ -333,25 +333,63 @@ in
|
|||||||
nomarchy-control-center # TUI control center
|
nomarchy-control-center # TUI control center
|
||||||
nomarchy-detect-hw # post-install hardware re-probe (HARDWARE.md §8)
|
nomarchy-detect-hw # post-install hardware re-probe (HARDWARE.md §8)
|
||||||
|
|
||||||
# Friendly wrappers for the two rebuild paths (README §3). Run as
|
# Day-to-day lifecycle (README §3). Always run as your user —
|
||||||
# your user: `nix flake update` must NOT run as root (libgit2
|
# `nix flake update` / git must not run as root (libgit2 refuses a
|
||||||
# refuses the user-owned flake repo) — sudo happens inside, only
|
# user-owned flake); sudo is only for the system switch.
|
||||||
# for the system switch.
|
#
|
||||||
(pkgs.writeShellScriptBin "sys-update" ''
|
# nomarchy-pull git pull (if checkout) + flake.lock update
|
||||||
|
# nomarchy-rebuild system switch against the *current* lock
|
||||||
|
# nomarchy-home Home Manager switch (desktop layer)
|
||||||
|
#
|
||||||
|
# Full distro upgrade: nomarchy-pull && nomarchy-rebuild && nomarchy-home
|
||||||
|
# Config-only system: nomarchy-rebuild
|
||||||
|
# Theme/desktop only: nomarchy-home
|
||||||
|
#
|
||||||
|
# Legacy names (sys-update / sys-rebuild / home-update) stay as
|
||||||
|
# thin wrappers so old docs and muscle memory keep working.
|
||||||
|
(pkgs.writeShellScriptBin "nomarchy-pull" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
echo "sys-update: run as your normal user (it sudos the rebuild itself)" >&2
|
echo "nomarchy-pull: run as your normal user" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
||||||
echo "sys-update: updating flake inputs in $flake"
|
if [ ! -d "$flake" ]; then
|
||||||
|
echo "nomarchy-pull: flake path not found: $flake" >&2
|
||||||
|
echo " Set NOMARCHY_PATH or clone/symlink your flake to ~/.nomarchy." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# 1) Your checkout (system.nix / home.nix / local edits).
|
||||||
|
if [ -d "$flake/.git" ]; then
|
||||||
|
echo "nomarchy-pull: git pull --ff-only in $flake"
|
||||||
|
git -C "$flake" pull --ff-only
|
||||||
|
else
|
||||||
|
echo "nomarchy-pull: $flake is not a git checkout — skipping git pull"
|
||||||
|
fi
|
||||||
|
# 2) Flake inputs (nixpkgs, nomarchy, home-manager, …).
|
||||||
|
echo "nomarchy-pull: nix flake update in $flake"
|
||||||
nix flake update --flake "$flake"
|
nix flake update --flake "$flake"
|
||||||
|
echo "nomarchy-pull: done — next: nomarchy-rebuild then nomarchy-home"
|
||||||
|
'')
|
||||||
|
(pkgs.writeShellScriptBin "nomarchy-rebuild" ''
|
||||||
|
set -euo pipefail
|
||||||
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
|
echo "nomarchy-rebuild: run as your normal user (it sudos the rebuild itself)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
||||||
|
if [ ! -d "$flake" ]; then
|
||||||
|
echo "nomarchy-rebuild: flake path not found: $flake" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
before=$(readlink -f /run/current-system)
|
before=$(readlink -f /run/current-system)
|
||||||
log=$(mktemp)
|
log=$(mktemp)
|
||||||
trap 'rm -f "$log"' EXIT
|
trap 'rm -f "$log"' EXIT
|
||||||
set +e
|
set +e
|
||||||
|
# Snapshot-first when snapper is on; pass flake path through sudo
|
||||||
|
# (nixos-rebuild-snap used to hardcode /etc/nixos).
|
||||||
if command -v nixos-rebuild-snap >/dev/null 2>&1; then
|
if command -v nixos-rebuild-snap >/dev/null 2>&1; then
|
||||||
sudo nixos-rebuild-snap "$@" 2>&1 | tee "$log"
|
sudo env NOMARCHY_PATH="$flake" nixos-rebuild-snap "$@" 2>&1 | tee "$log"
|
||||||
else
|
else
|
||||||
sudo nixos-rebuild switch --flake "$flake#default" "$@" 2>&1 | tee "$log"
|
sudo nixos-rebuild switch --flake "$flake#default" "$@" 2>&1 | tee "$log"
|
||||||
fi
|
fi
|
||||||
@@ -359,71 +397,32 @@ in
|
|||||||
set -e
|
set -e
|
||||||
if [ "$rc" -ne 0 ]; then
|
if [ "$rc" -ne 0 ]; then
|
||||||
echo
|
echo
|
||||||
echo "sys-update: rebuild FAILED (exit $rc). Last lines:"
|
echo "nomarchy-rebuild: FAILED (exit $rc). Last lines:"
|
||||||
tail -n 40 "$log" || true
|
tail -n 40 "$log" || true
|
||||||
echo
|
echo
|
||||||
echo "Diagnose: nomarchy-doctor"
|
echo "Diagnose: nomarchy-doctor"
|
||||||
echo "Recovery: docs/RECOVERY.md (boot menu generations / snapper)"
|
echo "Recovery: docs/RECOVERY.md (boot menu generations / snapper)"
|
||||||
exit "$rc"
|
exit "$rc"
|
||||||
fi
|
fi
|
||||||
# What did that update actually change? Package-level diff of the
|
|
||||||
# old vs new generation (the informative half of "informative +
|
|
||||||
# rock-stable"); never fails the run.
|
|
||||||
after=$(readlink -f /run/current-system)
|
after=$(readlink -f /run/current-system)
|
||||||
if [ "$before" = "$after" ]; then
|
if [ "$before" = "$after" ]; then
|
||||||
echo "sys-update: no changes — the system is identical."
|
echo "nomarchy-rebuild: no changes — the system is identical."
|
||||||
else
|
else
|
||||||
echo "sys-update: what changed:"
|
echo "nomarchy-rebuild: what changed:"
|
||||||
${pkgs.nvd}/bin/nvd diff "$before" "$after" || true
|
${pkgs.nvd}/bin/nvd diff "$before" "$after" || true
|
||||||
fi
|
fi
|
||||||
'')
|
'')
|
||||||
# The no-update twin (hardware-QA request): rebuild the system
|
(pkgs.writeShellScriptBin "nomarchy-home" ''
|
||||||
# against the CURRENT lock — config changes only, no `nix flake
|
|
||||||
# update` — mirroring how home-update never touches the lock.
|
|
||||||
# Same snapshot-first path when available.
|
|
||||||
(pkgs.writeShellScriptBin "sys-rebuild" ''
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
echo "sys-rebuild: run as your normal user (it sudos the rebuild itself)" >&2
|
echo "nomarchy-home: run as your normal user" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
||||||
before=$(readlink -f /run/current-system)
|
if [ ! -d "$flake" ]; then
|
||||||
log=$(mktemp)
|
echo "nomarchy-home: flake path not found: $flake" >&2
|
||||||
trap 'rm -f "$log"' EXIT
|
|
||||||
set +e
|
|
||||||
if command -v nixos-rebuild-snap >/dev/null 2>&1; then
|
|
||||||
sudo nixos-rebuild-snap "$@" 2>&1 | tee "$log"
|
|
||||||
else
|
|
||||||
sudo nixos-rebuild switch --flake "$flake#default" "$@" 2>&1 | tee "$log"
|
|
||||||
fi
|
|
||||||
rc=''${PIPESTATUS[0]}
|
|
||||||
set -e
|
|
||||||
if [ "$rc" -ne 0 ]; then
|
|
||||||
echo
|
|
||||||
echo "sys-rebuild: rebuild FAILED (exit $rc). Last lines:"
|
|
||||||
tail -n 40 "$log" || true
|
|
||||||
echo
|
|
||||||
echo "Diagnose: nomarchy-doctor"
|
|
||||||
echo "Recovery: docs/RECOVERY.md (boot menu generations / snapper)"
|
|
||||||
exit "$rc"
|
|
||||||
fi
|
|
||||||
# Same what-changed diff as sys-update (the twins stay twins).
|
|
||||||
after=$(readlink -f /run/current-system)
|
|
||||||
if [ "$before" = "$after" ]; then
|
|
||||||
echo "sys-rebuild: no changes — the system is identical."
|
|
||||||
else
|
|
||||||
echo "sys-rebuild: what changed:"
|
|
||||||
${pkgs.nvd}/bin/nvd diff "$before" "$after" || true
|
|
||||||
fi
|
|
||||||
'')
|
|
||||||
(pkgs.writeShellScriptBin "home-update" ''
|
|
||||||
set -euo pipefail
|
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
|
||||||
echo "home-update: run as your normal user" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
|
||||||
log=$(mktemp)
|
log=$(mktemp)
|
||||||
trap 'rm -f "$log"' EXIT
|
trap 'rm -f "$log"' EXIT
|
||||||
set +e
|
set +e
|
||||||
@@ -432,13 +431,25 @@ in
|
|||||||
set -e
|
set -e
|
||||||
if [ "$rc" -ne 0 ]; then
|
if [ "$rc" -ne 0 ]; then
|
||||||
echo
|
echo
|
||||||
echo "home-update: switch FAILED (exit $rc). Last lines:"
|
echo "nomarchy-home: FAILED (exit $rc). Last lines:"
|
||||||
tail -n 40 "$log" || true
|
tail -n 40 "$log" || true
|
||||||
echo
|
echo
|
||||||
echo "Diagnose: nomarchy-doctor"
|
echo "Diagnose: nomarchy-doctor"
|
||||||
echo "Recovery: home-manager generations (or docs/RECOVERY.md)"
|
echo "Recovery: home-manager generations (or docs/RECOVERY.md)"
|
||||||
exit "$rc"
|
exit "$rc"
|
||||||
fi
|
fi
|
||||||
|
echo "nomarchy-home: desktop applied."
|
||||||
|
'')
|
||||||
|
# Legacy aliases — same behaviour, old names.
|
||||||
|
(pkgs.writeShellScriptBin "sys-update" ''
|
||||||
|
# Was: flake update + system rebuild. Now the two explicit steps.
|
||||||
|
nomarchy-pull && nomarchy-rebuild "$@"
|
||||||
|
'')
|
||||||
|
(pkgs.writeShellScriptBin "sys-rebuild" ''
|
||||||
|
exec nomarchy-rebuild "$@"
|
||||||
|
'')
|
||||||
|
(pkgs.writeShellScriptBin "home-update" ''
|
||||||
|
exec nomarchy-home "$@"
|
||||||
'')
|
'')
|
||||||
|
|
||||||
git
|
git
|
||||||
@@ -461,12 +472,15 @@ in
|
|||||||
echo "This script must be run as root (use sudo)" >&2
|
echo "This script must be run as root (use sudo)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# Prefer the path nomarchy-rebuild passes through sudo; fall back
|
||||||
|
# for hand invocations.
|
||||||
|
flake="''${NOMARCHY_PATH:-/etc/nixos}"
|
||||||
echo "Creating pre-rebuild snapshot..."
|
echo "Creating pre-rebuild snapshot..."
|
||||||
${pkgs.snapper}/bin/snapper -c root create \
|
${pkgs.snapper}/bin/snapper -c root create \
|
||||||
-d "Pre-rebuild $(date +'%Y-%m-%d %H:%M:%S')" \
|
-d "Pre-rebuild $(date +'%Y-%m-%d %H:%M:%S')" \
|
||||||
--cleanup-algorithm number
|
--cleanup-algorithm number
|
||||||
echo "Rebuilding..."
|
echo "Rebuilding $flake#default ..."
|
||||||
nixos-rebuild switch --flake /etc/nixos#default "$@"
|
nixos-rebuild switch --flake "$flake#default" "$@"
|
||||||
'')
|
'')
|
||||||
# The desktop snapshot manager (browse / diff / restore / rollback over
|
# The desktop snapshot manager (browse / diff / restore / rollback over
|
||||||
# snapper, elevating via polkit) — the primary `nomarchy-menu snapshot`
|
# snapper, elevating via polkit) — the primary `nomarchy-menu snapshot`
|
||||||
|
|||||||
Reference in New Issue
Block a user