feat(core): migrate system state to unified declarative JSON
- Consolidate all configuration toggles (suspend, idle, waybar, etc.) into ~/.config/home-manager/state.json - Introduce nomarchy.toggles and nomarchy.hyprland options in Nix - Inject toggle states into all bin/ scripts via environment variables - Update toggle scripts to mutate JSON and trigger background rebuilds - Add a migration script to transition legacy flag files to the new format
This commit is contained in:
43
modules/home/state.nix
Normal file
43
modules/home/state.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
stateDir = "${config.home.homeDirectory}/.config/home-manager";
|
||||
|
||||
# Helper to read state from a file, with a default
|
||||
readState = file: default:
|
||||
if builtins.pathExists "${stateDir}/${file}" then
|
||||
let
|
||||
content = builtins.readFile "${stateDir}/${file}";
|
||||
cleanContent = lib.removeSuffix "\n" content;
|
||||
in
|
||||
if lib.hasSuffix ".json" file then
|
||||
builtins.fromJSON cleanContent
|
||||
else
|
||||
cleanContent
|
||||
else
|
||||
default;
|
||||
|
||||
# Unified state reading
|
||||
togglesState = readState "state.json" {};
|
||||
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;
|
||||
};
|
||||
nightlightTemperature = togglesState.nightlightTemperature or 4000;
|
||||
theme = togglesState.theme or "nord";
|
||||
wallpaper = togglesState.wallpaper or "";
|
||||
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;
|
||||
};
|
||||
fonts.monospace = togglesState.font or "JetBrainsMono Nerd Font";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user