diff --git a/core/home/options.nix b/core/home/options.nix index bbb8cb6..d309a98 100644 --- a/core/home/options.nix +++ b/core/home/options.nix @@ -1,47 +1,52 @@ { lib, pkgs, ... }: +let + # Defaults live in lib/state-schema.nix so they can't drift between this + # file, core/system/options.nix, and core/home/state.nix's `or` fallbacks. + schema = import ../../lib/state-schema.nix { inherit lib; }; +in { options.nomarchy = { toggles = { suspend = lib.mkOption { type = lib.types.bool; - default = true; + default = schema.home.suspend; description = "Whether to show suspend in system menu."; }; screensaver = lib.mkOption { type = lib.types.bool; - default = true; + default = schema.home.screensaver; description = "Whether the screensaver is enabled."; }; idle = lib.mkOption { type = lib.types.bool; - default = true; + default = schema.home.idle; description = "Whether the idle lock is enabled."; }; nightlight = lib.mkOption { type = lib.types.bool; - default = false; + default = schema.home.nightlight; description = "Whether the nightlight is enabled."; }; waybar = lib.mkOption { type = lib.types.bool; - default = true; + default = schema.home.waybar; description = "Whether the top bar is enabled."; }; skipVsCodeTheme = lib.mkOption { type = lib.types.bool; - default = false; + default = schema.home.skipVsCodeTheme; description = "Whether to skip theme changes in VSCode."; }; }; nightlightTemperature = lib.mkOption { type = lib.types.int; - default = 4000; + default = schema.home.nightlightTemperature; description = "Temperature for the nightlight."; }; theme = lib.mkOption { type = lib.types.str; - default = "summer-night"; + default = schema.home.theme; description = "System theme name."; }; formFactor = lib.mkOption { @@ -58,35 +63,35 @@ }; wallpaper = lib.mkOption { type = lib.types.str; - default = ""; + default = schema.home.wallpaper; description = "System wallpaper path."; }; panelPosition = lib.mkOption { type = lib.types.enum [ "top" "bottom" ]; - default = "top"; + default = schema.home.panelPosition; description = "Waybar panel position."; }; hyprland = { gaps_in = lib.mkOption { type = lib.types.int; - default = 5; + default = schema.home.hyprland.gaps_in; description = "Inner gaps for Hyprland."; }; gaps_out = lib.mkOption { type = lib.types.int; - default = 10; + default = schema.home.hyprland.gaps_out; description = "Outer gaps for Hyprland."; }; border_size = lib.mkOption { type = lib.types.int; - default = 2; + default = schema.home.hyprland.border_size; description = "Border size for Hyprland."; }; }; fonts = { monospace = lib.mkOption { type = lib.types.str; - default = "JetBrainsMono Nerd Font"; + default = schema.home.font; description = "System monospace font."; }; }; diff --git a/core/home/state.nix b/core/home/state.nix index ea01927..47b5860 100644 --- a/core/home/state.nix +++ b/core/home/state.nix @@ -2,6 +2,12 @@ let nomarchyLib = import ../../lib { inherit lib; }; + # Single source of truth for default values when state.json is missing + # a key. Both core/system/options.nix and core/home/options.nix read + # from this same file — changing a default in one place updates + # everywhere. (Was: each consumer hardcoded its own `or X` literal, + # which is how the summer-night/nord split lived for so long.) + schema = import ../../lib/state-schema.nix { inherit lib; }; assetsPath = ../../themes/palettes; # Read unified state from ~/.config/nomarchy/state.json @@ -11,31 +17,31 @@ in config = { nomarchy = { toggles = { - suspend = togglesState.suspend or true; - screensaver = togglesState.screensaver or true; - idle = togglesState.idle or true; - nightlight = togglesState.nightlight or false; - waybar = togglesState.waybar or true; - skipVsCodeTheme = togglesState.skipVsCodeTheme or false; + suspend = togglesState.suspend or schema.home.suspend; + screensaver = togglesState.screensaver or schema.home.screensaver; + idle = togglesState.idle or schema.home.idle; + nightlight = togglesState.nightlight or schema.home.nightlight; + waybar = togglesState.waybar or schema.home.waybar; + skipVsCodeTheme = togglesState.skipVsCodeTheme or schema.home.skipVsCodeTheme; }; - nightlightTemperature = togglesState.nightlightTemperature or 4000; - theme = togglesState.theme or "nord"; - wallpaper = togglesState.wallpaper or ""; - panelPosition = togglesState.panelPosition or "top"; + nightlightTemperature = togglesState.nightlightTemperature or schema.home.nightlightTemperature; + theme = togglesState.theme or schema.home.theme; + wallpaper = togglesState.wallpaper or schema.home.wallpaper; + panelPosition = togglesState.panelPosition or schema.home.panelPosition; hyprland = { - gaps_in = togglesState.hyprland.gaps_in or 5; - gaps_out = togglesState.hyprland.gaps_out or 10; - border_size = togglesState.hyprland.border_size or 2; + gaps_in = togglesState.hyprland.gaps_in or schema.home.hyprland.gaps_in; + gaps_out = togglesState.hyprland.gaps_out or schema.home.hyprland.gaps_out; + border_size = togglesState.hyprland.border_size or schema.home.hyprland.border_size; }; - fonts.monospace = togglesState.font or "JetBrainsMono Nerd Font"; + fonts.monospace = togglesState.font or schema.home.font; # Derived properties from the theme directory isLightMode = nomarchyLib.isThemeLightMode { - themeName = togglesState.theme or "nord"; + themeName = togglesState.theme or schema.home.theme; inherit assetsPath; }; iconsTheme = nomarchyLib.getIconsTheme { - themeName = togglesState.theme or "nord"; + themeName = togglesState.theme or schema.home.theme; inherit assetsPath; }; }; diff --git a/core/system/options.nix b/core/system/options.nix index 97b0bd6..dbb5e60 100644 --- a/core/system/options.nix +++ b/core/system/options.nix @@ -1,27 +1,32 @@ { config, lib, pkgs, ... }: +let + # Defaults live in lib/state-schema.nix so they can't drift between this + # file, core/home/options.nix, and core/home/state.nix's `or` fallbacks. + schema = import ../../lib/state-schema.nix { inherit lib; }; +in { options.nomarchy.system = { dns = lib.mkOption { type = lib.types.enum [ "Cloudflare" "Google" "DHCP" "Custom" ]; - default = "DHCP"; + default = schema.system.dns; description = "Selected DNS provider."; }; customDns = lib.mkOption { type = lib.types.listOf lib.types.str; - default = []; + default = schema.system.customDns; description = "List of custom DNS servers."; }; wifi = { powersave = lib.mkOption { type = lib.types.bool; - default = true; + default = schema.system.wifi.powersave; description = "Whether to enable wifi power saving."; }; }; timezone = lib.mkOption { type = lib.types.str; - default = "UTC"; + default = schema.system.timezone; description = "System timezone."; }; formFactor = lib.mkOption { @@ -39,24 +44,24 @@ features = { fingerprint = lib.mkOption { type = lib.types.bool; - default = false; + default = schema.system.features.fingerprint; description = "Whether to enable fingerprint support."; }; fido2 = lib.mkOption { type = lib.types.bool; - default = false; + default = schema.system.features.fido2; description = "Whether to enable FIDO2 support."; }; hybridGPU = lib.mkOption { type = lib.types.bool; - default = false; + default = schema.system.features.hybridGPU; description = "Whether to enable hybrid GPU support (supergfxd)."; }; }; theme = lib.mkOption { type = lib.types.str; - default = "nord"; - description = "Selected system theme. Matches lib/state-schema.nix and the installer-written state.json so a missing/blank state file lands on the same theme everywhere."; + default = schema.system.theme; + description = "Selected system theme."; }; # ----- Tier 1 system features (all opt-in, no behavioural change off) --- diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 9026127..1512892 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -121,6 +121,7 @@ Each PR description should reference the row(s) in `docs/SCRIPTS.md` it closes, (Move items here when they land — keep them brief, link the commit/PR.) +- _2026-05-18_ — Declarative-state defaults centralization. Made `lib/state-schema.nix` the single source of truth for every state-default that previously lived in three places (the schema itself, `core/system/options.nix` / `core/home/options.nix` `default = …` clauses, and `core/home/state.nix` `or …` fallbacks). Replaced ~25 hardcoded literals with `schema..` reads. Side-effect: fixed a lingering bug where `core/home/options.nix:theme` still defaulted to `"summer-night"` after the system-side was moved to `"nord"` — half the codebase's home option resolved to the wrong theme when state.json was missing/blank. `nix flake check --no-build` confirms zero semantic change for every other field. Doesn't touch the installer-written `state.json` (separate batch — needs schema → JSON generation). - _2026-05-18_ — Pillar 7 first step: Forgejo Actions CI (eval + lint). New `.forgejo/workflows/check.yml` runs on every push to `main` and every PR: (1) `nix flake check --no-build` to catch eval regressions, (2) `bash -n` + `shellcheck --severity=error` over every `nomarchy-*` bash script (whole-tree, not just changed files — gates branches that bypass the pre-commit hook), (3) `docs/SCRIPTS.md` drift check (fails loudly if a script change didn't regenerate the audit doc). All three checks pass locally on the current tree. Activation requires enabling Actions on the Forgejo repo and registering a `forgejo-runner`; the workflow itself is dormant until then. ISO build job is intentionally deferred — needs a binary cache (Cachix/Attic) to be tractable. - _2026-05-18_ — **Pillar 3 Phase B: complete.** Final batch (restart/sudo/theme/misc clusters) cleared the last 13 `unused?` rows. Deleted five truly dead scripts: `nomarchy-restart-{hyprctl,mako}` (theme switching calls `hyprctl reload`/`makoctl reload` directly now), `nomarchy-restart-tmux` (one-liner of marginal value), `nomarchy-battery-present` (battery monitor checks `/sys/class/power_supply/BAT*` inline), `nomarchy-sudo-keepalive` (intended-to-be-sourced building block with no users). Surfaced eight useful tools in `SKILL.md` so the audit catches them as `kept` and AI assistants can discover them: `nomarchy-restart-trackpad` (intel_quicki2c reload), `nomarchy-sudo-{passwordless-toggle,reset}`, `nomarchy-theme-{bg-install,refresh,remove}`, `nomarchy-refresh-fastfetch`, `nomarchy-windows-vm` (new Virtualization section). Final state: 159 scripts, all `kept`, `unused?` = 0, missing references = 0. - _2026-05-18_ — Pillar 3 Phase B: webapp/tui/voxtype install-remove pair triage. Deleted two dead webapp URI handlers (`nomarchy-webapp-handler-hey`, `nomarchy-webapp-handler-zoom`) — no `.desktop` MimeType registration anywhere routed `mailto:`/`zoom:` URIs to them, so the handlers could never fire. Surfaced six useful CLI tools in `SKILL.md` "Common Tasks" so they're discoverable by AI assistants and tagged `kept` by the audit: `nomarchy-webapp-{remove,remove-all}`, `nomarchy-tui-{remove,remove-all}`, `nomarchy-voxtype-{install,remove}`. Script count 166 → 164; `unused?` 21 → 13.