refactor(#107): theme-state.json → state.json, theme-sync → state-sync
Some checks failed
Check / eval (push) Has been cancelled
Some checks failed
Check / eval (push) Has been cancelled
The machine flake's git-tracked settings file is system state, not "theme" only — rename it to state.json. CLI becomes nomarchy-state-sync with a nomarchy-theme-sync symlink for scripts and muscle memory. Eval (mkFlake, doctor, lifecycle) still accepts theme-state.json; the next write migrates to state.json and removes the legacy file. Documented in MIGRATION.md; drop the CLI alias after release notes.
This commit is contained in:
21
lib.nix
21
lib.nix
@@ -1,5 +1,5 @@
|
||||
# Downstream sugar: one call wires a whole machine flake.
|
||||
# Users own ONLY system.nix, home.nix and theme-state.json; their flake.nix
|
||||
# Users own ONLY system.nix, home.nix and state.json; their flake.nix
|
||||
# is generated once (by `nix flake init -t` or the future installer) and
|
||||
# never hand-edited. The raw exports (nixosModules/homeModules/overlays)
|
||||
# in flake.nix remain the escape hatch for power users.
|
||||
@@ -8,9 +8,9 @@
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
# Shared pure reader (modules/theme-state-read.nix) — re-exported so
|
||||
# Shared pure reader (modules/state-read.nix) — re-exported so
|
||||
# power users composing without mkFlake can call it too.
|
||||
readThemeState = import ./modules/theme-state-read.nix { inherit lib; };
|
||||
readThemeState = import ./modules/state-read.nix { inherit lib; };
|
||||
in
|
||||
{
|
||||
inherit readThemeState;
|
||||
@@ -59,13 +59,18 @@ in
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
|
||||
# Early fail-closed gate: missing/empty/non-object theme-state.json
|
||||
# Early fail-closed gate: missing/empty/non-object state.json
|
||||
# throws here with a template + validate pointer, before module
|
||||
# evaluation buries a raw readFile/fromJSON stack. Field-level
|
||||
# schema still runs in modules/home/theme.nix after defaults merge.
|
||||
# Forced via seq on the whole return set — attrNames alone must not
|
||||
# skip the check (Nix is lazy on unused let bindings and attr values).
|
||||
statePath = src + "/theme-state.json";
|
||||
# #107: prefer state.json; accept legacy theme-state.json until
|
||||
# the user's next menu write migrates them.
|
||||
statePath =
|
||||
if builtins.pathExists (src + "/state.json") then src + "/state.json"
|
||||
else if builtins.pathExists (src + "/theme-state.json") then src + "/theme-state.json"
|
||||
else src + "/state.json";
|
||||
_themeState = readThemeState statePath;
|
||||
in
|
||||
builtins.seq _themeState {
|
||||
@@ -78,7 +83,7 @@ in
|
||||
[
|
||||
nomarchy.nixosModules.nomarchy
|
||||
# The standalone HM CLI ships with the system so theme switching
|
||||
# (`nomarchy-theme-sync apply` → `home-manager switch`) works
|
||||
# (`nomarchy-state-sync apply` → `home-manager switch`) works
|
||||
# out of the box — same pinned input as the desktop modules.
|
||||
{ environment.systemPackages = [ home-manager.packages.${system}.home-manager ]; }
|
||||
# System-side theme consumers (Plymouth splash background)
|
||||
@@ -94,14 +99,14 @@ in
|
||||
|
||||
# Desktop layer — every theme change, no sudo:
|
||||
# home-manager switch --flake .#<username>
|
||||
# (`nomarchy-theme-sync apply` runs this for you.)
|
||||
# (`nomarchy-state-sync apply` runs this for you.)
|
||||
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
nomarchy.homeModules.nomarchy
|
||||
(src + "/home.nix")
|
||||
{
|
||||
# Written by nomarchy-theme-sync; reading it is pure — the
|
||||
# Written by nomarchy-state-sync; reading it is pure — the
|
||||
# file is part of the downstream flake's source.
|
||||
nomarchy.stateFile = statePath;
|
||||
home = {
|
||||
|
||||
Reference in New Issue
Block a user