Kills a recurring bug class: state defaults previously lived in three
parallel places that drifted apart over time.
- lib/state-schema.nix (the canonical schema, referenced
nowhere except a description string)
- core/system/options.nix (default = "..." clauses on options)
- core/home/options.nix (same, on home options)
- core/home/state.nix (`or "..."` fallbacks for state.json reads)
When `state.json` is missing a key, three files have to agree on the
fallback. They keep silently drifting:
- The OOTB QA audit shipped fixes for this pattern.
- Earlier this session, `chore: switch default theme summer-night → nord`
fixed core/system/options.nix and core/home/state.nix — but missed
core/home/options.nix, which still defaulted nomarchy.theme to
"summer-night". Every consumer of the home option
(features/default.nix, vscode.nix, waybar, hyprland, theme engine)
resolved to the wrong theme when state.json was blank.
This change:
- Imports lib/state-schema.nix into all three consumers and replaces
every hardcoded default with `schema.<scope>.<key>`.
- Fixes the lingering nomarchy.theme = "summer-night" home-side bug as
a side-effect.
- Touches roughly 25 literals across the three files.
Verified `nix flake check --no-build` passes and every centralized value
evaluates to the exact literal it previously had. Off-schema option-only
defaults (isLightMode, formFactor, cursor.*, iconsTheme, keyring.enable,
etc.) are left hardcoded — they have no state.json counterpart, so
there's no source-of-truth split to resolve.
Out of scope (follow-up):
- Have installer/install.sh generate /mnt/etc/nixos/state.json from
the schema instead of hardcoded JSON — would close the last
split-brain surface (the installer can still drift from schema).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
149 lines
4.8 KiB
Nix
149 lines
4.8 KiB
Nix
{ 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 = schema.home.suspend;
|
|
description = "Whether to show suspend in system menu.";
|
|
};
|
|
screensaver = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = schema.home.screensaver;
|
|
description = "Whether the screensaver is enabled.";
|
|
};
|
|
idle = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = schema.home.idle;
|
|
description = "Whether the idle lock is enabled.";
|
|
};
|
|
nightlight = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = schema.home.nightlight;
|
|
description = "Whether the nightlight is enabled.";
|
|
};
|
|
waybar = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = schema.home.waybar;
|
|
description = "Whether the top bar is enabled.";
|
|
};
|
|
skipVsCodeTheme = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = schema.home.skipVsCodeTheme;
|
|
description = "Whether to skip theme changes in VSCode.";
|
|
};
|
|
};
|
|
nightlightTemperature = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = schema.home.nightlightTemperature;
|
|
description = "Temperature for the nightlight.";
|
|
};
|
|
theme = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = schema.home.theme;
|
|
description = "System theme name.";
|
|
};
|
|
formFactor = lib.mkOption {
|
|
type = lib.types.enum [ "laptop" "desktop" ];
|
|
default = "laptop";
|
|
description = ''
|
|
Physical form factor. Drives UI affordances (battery widget,
|
|
future lid handling). Default "laptop" — battery widget is
|
|
harmless on a desktop (renders empty when no BAT* is present),
|
|
so the safe default is "show, don't hide". The installer
|
|
auto-detects via /sys/class/power_supply/BAT* and writes the
|
|
explicit value into the generated home.nix.
|
|
'';
|
|
};
|
|
wallpaper = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = schema.home.wallpaper;
|
|
description = "System wallpaper path.";
|
|
};
|
|
panelPosition = lib.mkOption {
|
|
type = lib.types.enum [ "top" "bottom" ];
|
|
default = schema.home.panelPosition;
|
|
description = "Waybar panel position.";
|
|
};
|
|
hyprland = {
|
|
gaps_in = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = schema.home.hyprland.gaps_in;
|
|
description = "Inner gaps for Hyprland.";
|
|
};
|
|
gaps_out = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = schema.home.hyprland.gaps_out;
|
|
description = "Outer gaps for Hyprland.";
|
|
};
|
|
border_size = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = schema.home.hyprland.border_size;
|
|
description = "Border size for Hyprland.";
|
|
};
|
|
};
|
|
fonts = {
|
|
monospace = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = schema.home.font;
|
|
description = "System monospace font.";
|
|
};
|
|
};
|
|
iconsTheme = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "Yaru-blue";
|
|
description = "System icon theme name.";
|
|
};
|
|
isLightMode = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Whether the current theme is light mode.";
|
|
};
|
|
cursor = {
|
|
name = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "Bibata-Modern-Ice";
|
|
description = "Mouse cursor theme name.";
|
|
};
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.bibata-cursors;
|
|
description = "Package providing the cursor theme.";
|
|
};
|
|
};
|
|
configOverrides = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.path;
|
|
default = null;
|
|
description = "Path to a directory containing configuration overrides.";
|
|
};
|
|
|
|
apps = {
|
|
opencode = {
|
|
enable = lib.mkEnableOption ''
|
|
opencode AI coding CLI integration. When on, deploys
|
|
~/.config/opencode/opencode.json. The `opencode` package itself
|
|
is not installed by Nomarchy — add it to your home.nix if you
|
|
want it on PATH.
|
|
'';
|
|
};
|
|
};
|
|
|
|
gaming = {
|
|
enable = lib.mkEnableOption ''
|
|
Gaming preset (home-side companion to nomarchy.system.gaming.enable).
|
|
Adds a Hyprland window rule that fullscreens windows whose class
|
|
matches steam_app_* — i.e. games launched through Steam — so they
|
|
grab the whole screen instead of opening windowed. Set this to the
|
|
same value as nomarchy.system.gaming.enable; the installer flips
|
|
both when the Gaming profile is selected.
|
|
'';
|
|
};
|
|
};
|
|
}
|