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>
50 lines
2.1 KiB
Nix
50 lines
2.1 KiB
Nix
{ config, lib, ... }:
|
|
|
|
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
|
|
togglesState = nomarchyLib.readHomeState config.home.homeDirectory;
|
|
in
|
|
{
|
|
config = {
|
|
nomarchy = {
|
|
toggles = {
|
|
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 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 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 schema.home.font;
|
|
|
|
# Derived properties from the theme directory
|
|
isLightMode = nomarchyLib.isThemeLightMode {
|
|
themeName = togglesState.theme or schema.home.theme;
|
|
inherit assetsPath;
|
|
};
|
|
iconsTheme = nomarchyLib.getIconsTheme {
|
|
themeName = togglesState.theme or schema.home.theme;
|
|
inherit assetsPath;
|
|
};
|
|
};
|
|
};
|
|
}
|