From c385cd3713db854f47d903d01d17263f8320b134 Mon Sep 17 00:00:00 2001 From: rope Date: Sun, 9 Aug 2026 09:07:59 +0100 Subject: [PATCH] macbook: drop nom, store auto-optimise, halve substitution jobs Co-Authored-By: Claude Opus 5 --- common.nix | 17 +++++++++++++++-- hosts/FredOS-Macbook.nix | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common.nix b/common.nix index 229139e..6330900 100644 --- a/common.nix +++ b/common.nix @@ -1,6 +1,15 @@ # Common.nix { config, pkgs, lib, inputs, ... }: +let + isMacbook = config.networking.hostName == "FredOS-Macbook"; + + # nom's Haskell renderer measured 91% CPU during a rebuild — a full core of + # the Macbook's four, spent drawing a progress tree, while nix itself wanted + # 146%. Plain `-L` output there; the other hosts can afford the pretty one. + buildLog = lib.optionalString (!isMacbook) + " --log-format internal-json 2>&1 | nom --json"; +in { imports = [ # Host modules are imported per-host by mkHost in flake.nix. @@ -111,7 +120,7 @@ # Shell aliases (work in both bash and fish) environment.shellAliases = { - update = "bash -c 'set -o pipefail && OLD_SYSTEM=$(readlink /run/current-system) && sudo nixos-rebuild switch $@ --refresh --flake git+https://forg.gregersen.it/rope/nixos -L --log-format internal-json 2>&1 | nom --json && nvd diff $OLD_SYSTEM /run/current-system && (command -v record-update &>/dev/null && record-update $OLD_SYSTEM /run/current-system || true)' --"; + update = "bash -c 'set -o pipefail && OLD_SYSTEM=$(readlink /run/current-system) && sudo nixos-rebuild switch $@ --refresh --flake git+https://forg.gregersen.it/rope/nixos -L${buildLog} && nvd diff $OLD_SYSTEM /run/current-system && (command -v record-update &>/dev/null && record-update $OLD_SYSTEM /run/current-system || true)' --"; clean = "sudo nix-collect-garbage -d"; ll = "ls -alh"; clear = "command clear"; @@ -131,7 +140,11 @@ # Hard-link identical files in the store as new paths are added, so the # store de-duplicates itself on every build instead of drifting. - nix.settings.auto-optimise-store = true; + # Off on the Macbook: it hashes and relinks every file the daemon writes, + # which lands on top of the substitution writes on a slow SATA blade — + # measured io pressure full avg60=57% during a rebuild. Run `nix store + # optimise` by hand there if the store ever gets fat. + nix.settings.auto-optimise-store = !isMacbook; # Offload builds to the media server. Excluded on the server itself to # avoid a pointless SSH round-trip to localhost. diff --git a/hosts/FredOS-Macbook.nix b/hosts/FredOS-Macbook.nix index de069cc..55e74f5 100644 --- a/hosts/FredOS-Macbook.nix +++ b/hosts/FredOS-Macbook.nix @@ -25,7 +25,9 @@ # out-of-tree broadcom_sta (wl) driver drops association mid-build — # only a manual wifi reconnect brings it back. Cap the concurrency. nix.settings.http-connections = 8; - nix.settings.max-substitution-jobs = 4; + # 2, not 4: each job is an xz/zstd decompress, and there are only 4 threads + # to share with the desktop. 4 just queues them behind each other. + nix.settings.max-substitution-jobs = 2; services.tlp.enable = false; services.power-profiles-daemon.enable = true;