Recently Written · git

waybase

Bootable installer: KISS, Gentoo, Arch or Alpine + Nix + a Wayland compositor (sway, river, labwc, dwl)

git clone https://github.com/equwal/waybase

Log | Files | Refs


commit b09a1bd0bf5a4ed45000471621c5bfed0c9bdc8b
equwal <13551856+equwal@users.noreply.github.com>
2026-10-04 19:02:53 -0700

docs: example sysupdate and Nix compile script with GC trap

 docs/nix-compile.example | 28 ++++++++++++++++++++++++++++
 docs/sysupdate.example   | 17 +++++++++++++++++
 2 files changed, 45 insertions(+)
diff --git a/docs/nix-compile.example b/docs/nix-compile.example
new file mode 100644
index 0000000..ac3793b
--- /dev/null
+++ b/docs/nix-compile.example
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Rebuild the Nix profiles; collect garbage at start, after each build and on exit.
+# Edit the paths and attributes for your sys.nix. Run as root.
+set -u
+cd "$(dirname "$0")" || exit 1
+mkdir -p compile-logs
+LOG=compile-logs/compile-log-$(date +%Y%m%d-%H%M%S).txt
+
+# the store needs room for build inputs: drop old generations, then collect garbage
+gc_cleanup() {
+	echo "== gc_cleanup ($1)"; df -h /nix | tail -1
+	nix-collect-garbage -d >/dev/null 2>&1
+	df -h /nix | tail -1
+}
+
+build() { NIXPKGS_ALLOW_UNFREE=1 nix-build sys.nix -A "$1" -o "$2"; }
+
+main() {
+	trap 'gc_cleanup exit' EXIT
+	rc=0
+	gc_cleanup start
+	build user /usr/local/nix-user || rc=1
+	gc_cleanup after-user
+	build system /usr/local/nix-system || rc=1
+	echo "== done rc=$rc"
+	return $rc
+}
+main 2>&1 | tee -a "$LOG"
diff --git a/docs/sysupdate.example b/docs/sysupdate.example
new file mode 100644
index 0000000..c82b73d
--- /dev/null
+++ b/docs/sysupdate.example
@@ -0,0 +1,17 @@
+#!/bin/sh -e
+# Update everything: system packages, Nix, then each source repo in the list below.
+# Copy to a directory on PATH and edit the list and the commands for your system.
+# system packages: replace with your distro's updater (kiss update, apt upgrade, ...)
+kiss update
+# Nix: rebuild the system profile with the compile script from nix-compile.example
+su -c '/path/to/nix-compile.sh'
+# format: "dir mode [build command]"; custom = merge upstream into a patched branch, shell on conflict
+while read -r dir mode build <&3; do
+	cd "$dir" || continue
+	git pull --ff-only || true
+	[ "$mode" = custom ] && { git remote set-head origin -a >/dev/null && git merge origin/HEAD || ${SHELL:-sh}; }
+	[ -z "$build" ] || sh -c "$build"
+done 3<<EOF
+# $HOME/src/patched-project custom make && su -c 'make install'
+# $HOME/src/plain-project pull
+EOF