Drop the zram Module and enable zram inline on neogaia

modules/zram.nix only wrapped the native zramSwap.enable toggle without
adding anything. Rewrite the touched comments to describe only the current
file content, and record the in-file-comment convention in CLAUDE.md.
This commit is contained in:
2026-07-18 15:41:43 -04:00
parent 6c1ebfdd5f
commit 96f2de54ca
5 changed files with 15 additions and 31 deletions

View File

@@ -15,7 +15,7 @@ The kernel is selected through a small per-`Host` kernel mechanism so other `Hos
- [x] The chaotic substituter and trusted public key are in the Nix settings, so the kernel is fetched from cache rather than compiled.
- [x] Intel microcode is enabled.
- [x] Redistributable firmware is enabled so the QCA6174 wifi hardware is available.
- [x] A zram toggle `Module` exists (following the `Enable convention`) and is enabled on `neogaia`.
- [-] A zram toggle `Module` exists (following the `Enable convention`) and is enabled on `neogaia`. — Module dropped in PR review; zram is enabled inline on `neogaia` instead (see notes).
- [x] The `neogaia` toplevel still builds with all of the above.
## Implementation Notes
@@ -23,5 +23,4 @@ The kernel is selected through a small per-`Host` kernel mechanism so other `Hos
- **Per-`Host` kernel mechanism = native `boot.kernelPackages`.** neogaia sets `boot.kernelPackages = pkgs.linuxPackages_cachyos` directly in its Host directory (`hosts/neogaia/default.nix`). No custom wrapper option was added: `boot.kernelPackages` is already a per-`Host` setting, so other `Host`s pick their own kernel the same way. A string→package wrapper would have been premature abstraction with one `Host` and one kernel, so it was deliberately left out; the "mechanism" is the per-`Host` placement of the native option.
- **Substituter/key live in the shared base, via the `extra-` options.** They were added to `system/default.nix` (shared by every `Host`), not just neogaia, because the chaotic module is wired for all `Host`s and the cache is general plumbing. `nix.settings.extra-substituters` / `extra-trusted-public-keys` are used rather than the replacing `substituters` / `trusted-public-keys`, so `cache.nixos.org` (and any other substituter) is only appended to, never dropped. chaotic's own module also provides these entries; the explicit declaration is belt-and-suspenders and keeps the built system's cache config visible and independent of that module.
- **Dev-host build needed a daemon-level cache.** Building the toplevel here first compiled the CachyOS kernel (and rustc bootstrap) from source, because the build daemon's `/etc/nix/nix.conf` had no `nyx-cache` substituter — the built system's `nix.settings` do not govern the daemon doing the build, and the dev user is a non-trusted client that cannot add substituters from the CLI. Adding `extra-substituters`/`extra-trusted-public-keys` for `nyx-cache` to `/etc/nix/nix.conf` (sudo) and restarting `nix-daemon` fixed it; the build then fetched the kernel (7.1.3) from the cache. Recorded as a gotcha in `CLAUDE.md`.
- **zram `Module` kept minimal.** `modules/zram.nix` is a pure toggle (`zramSwap.enable = true` under `mkIf`), following the `modules/example.nix` reference shape. This preserves task 0002's exact behaviour while moving the switch behind the `Enable convention`; the direct `zramSwap.enable = true` previously inline in the `Host` was removed in favour of `modules.zram.enable = true`.
- **Why zram graduated to a `Module` but kernel/microcode/firmware stayed inline.** zram is a reusable, cross-`Host` feature toggle (the spec calls for it as a `Module`), whereas the kernel choice, Intel microcode, and firmware are neogaia-specific hardware facts that belong to the `Host` itself.
- **zram is enabled inline, not as a `Module` (criterion 5 dropped).** The task asked for a zram toggle `Module`, and one was built first (`modules/zram.nix`), but PR review rejected it as a single-line abstraction that wraps the native `zramSwap.enable` toggle without adding anything. It was removed, and `neogaia` sets `zramSwap.enable = true` directly, as it did before task 0003. The `Enable convention` reference remains `modules/example.nix`; real feature `Module`s arrive with fish/tmux/nvim/Claude Code in later tasks.

View File

@@ -3,6 +3,13 @@
One flake that builds every machine the user owns.
The domain model (Host, Module, Skeleton, Auto-loader, Enable convention, overlays) lives in `.claude/CONTEXT.md`; the current deliverable's spec is `.claude/spec/laptop-mvi.md`.
## Conventions
- In-file comments describe only the current content and behaviour of the file they sit in.
Do not write comments about history ("used to be X", "now moved here"), about how a value is consumed in other files, or that justify the choice against alternatives.
Never reference agent-facing state (anything under `.claude/` or `CLAUDE.md`) from a code comment: that state is not part of understanding the code.
A reader looking at only that file should find every comment accurate and self-contained.
## Gotchas
- Nix on the dev host needs experimental features passed per-command.

View File

@@ -17,10 +17,7 @@
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Kernel is a per-Host choice, expressed through boot.kernelPackages: neogaia
# runs the CachyOS kernel from chaotic-nyx (fetched from the chaotic binary
# cache wired in system/, not compiled from source). Other Hosts pick their
# own kernel the same way, so the choice never leaves the Host.
# neogaia runs the CachyOS kernel, selected per-Host via boot.kernelPackages.
boot.kernelPackages = pkgs.linuxPackages_cachyos;
# Intel CPU microcode updates for the XPS 13's Core i7-8565U.
@@ -29,7 +26,6 @@
# Redistributable firmware — carries the ath10k blobs the QCA6174 wifi needs.
hardware.enableRedistributableFirmware = true;
# Swap is RAM-backed zram (the zram Module) rather than an on-disk partition,
# matching the disko layout, which declares no swap partition.
modules.zram.enable = true;
# Swap is RAM-backed zram rather than an on-disk partition.
zramSwap.enable = true;
}

View File

@@ -1,14 +0,0 @@
{ config, lib, ... }:
# A toggle for RAM-backed swap. A Host that has no on-disk swap partition (like
# neogaia, whose disko layout deliberately omits one) enables this to get a
# compressed zram device instead.
let
cfg = config.modules.zram;
in
{
options.modules.zram.enable = lib.mkEnableOption "zram-backed compressed swap";
config = lib.mkIf cfg.enable {
zramSwap.enable = true;
};
}

View File

@@ -52,13 +52,9 @@ in
"flakes"
];
# The chaotic binary cache, declared explicitly on the built system so the
# CachyOS kernel is substituted rather than compiled. chaotic's own module
# also provides these, but stating them here keeps the built system's cache
# config visible and independent of that module. Added via the `extra-`
# options so they only append — cache.nixos.org and any other substituter
# are never dropped. (Fetching at install time depends on the installing
# daemon's substituters, not this — see the chaotic gotcha in CLAUDE.md.)
# The chaotic binary cache, so the CachyOS kernel is substituted rather than
# compiled. Appended with the `extra-` options so cache.nixos.org and any
# other substituter are kept alongside it.
nix.settings.extra-substituters = [ "https://nyx-cache.chaotic.cx/" ];
nix.settings.extra-trusted-public-keys = [
"nyx-cache.chaotic.cx:dJxTrgMC3V3cFfyIiBQDQorG6k1LsqurH/srpMSq7qk="