Files
Nomarchy/modules/home/state.nix
Bernardo Magri cfd5e4bb65 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
2026-04-04 10:11:09 +01:00

44 lines
1.3 KiB
Nix

{ 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";
};
}