fix(theme): #66 fail-closed theme-state errors at mkFlake/read
Missing, empty, or non-object theme-state.json now throws a short message pointing at the template and `nomarchy-theme-sync validate` instead of a raw readFile/fromJSON stack. Shared reader: modules/theme-state-read.nix — wired in theme.nix, plymouth/timezone/ hardware, and lib.mkFlake (seq-forced early gate). Field-level schema in theme.nix kept; unknown border roles still fail there; resolveColor no longer falls through on missing palette keys. Defaults added for settings.displayProfile / displayProfileAuto. Verified: V0 nix flake check --no-build; negative evals (missing, empty, [], bad border role); good-path template mode + displayProfile defaults.
This commit is contained in:
@@ -16,10 +16,11 @@
|
||||
let
|
||||
cfg = config.nomarchy.hardware;
|
||||
# Fingerprint PAM can follow theme-state.json (menu toggle → next
|
||||
# sys-rebuild), same bridge as autoTimezone (BACKLOG #55).
|
||||
# sys-rebuild), same bridge as autoTimezone (BACKLOG #55). Missing or
|
||||
# invalid JSON fails closed (theme-state-read.nix) instead of a raw stack.
|
||||
hwState =
|
||||
if config.nomarchy.system.stateFile != null
|
||||
then builtins.fromJSON (builtins.readFile config.nomarchy.system.stateFile)
|
||||
then import ../theme-state-read.nix { inherit lib; } config.nomarchy.system.stateFile
|
||||
else { };
|
||||
pamFromState = (hwState.settings or { }).fingerprint.pam or false;
|
||||
in
|
||||
|
||||
@@ -12,7 +12,7 @@ let
|
||||
|
||||
state =
|
||||
if cfg.stateFile != null
|
||||
then builtins.fromJSON (builtins.readFile cfg.stateFile)
|
||||
then import ../theme-state-read.nix { inherit lib; } cfg.stateFile
|
||||
else { };
|
||||
colorOf = key: fallback: lib.removePrefix "#" ((state.colors or { }).${key} or fallback);
|
||||
# Fallbacks match the distro default theme (Boreal) when stateFile is null.
|
||||
|
||||
@@ -15,10 +15,11 @@ let
|
||||
cfg = config.nomarchy.system;
|
||||
|
||||
# Read the same state file the rest of the system side uses (Plymouth too),
|
||||
# wired by lib.mkFlake. The flag defaults off when the file is absent/sparse.
|
||||
# wired by lib.mkFlake. The flag defaults off when stateFile is null;
|
||||
# a set-but-missing/invalid path fails closed via theme-state-read.nix.
|
||||
state =
|
||||
if cfg.stateFile != null
|
||||
then builtins.fromJSON (builtins.readFile cfg.stateFile)
|
||||
then import ../theme-state-read.nix { inherit lib; } cfg.stateFile
|
||||
else { };
|
||||
stateEnabled = (state.settings or { }).autoTimezone or false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user