features/desktop/nightlight.nix previously set
`services.hyprsunset.enable = lib.mkDefault true` unconditionally and
baked the temperature (4000K when toggles.nightlight, 6500K otherwise)
into extraArgs at Nix-eval time. The toggle script bypassed systemd:
pkill on disable, `hyprctl dispatch exec hyprsunset --temperature 4000`
on enable — racing the systemd-managed instance and hardcoding 4000K
regardless of nomarchy.nightlightTemperature. The "Always enabled, we
control via IPC and state" comment was misleading: no IPC, the
temperature was rebuild-time, and the script forked a parallel
process.
Path (b) from the Later row:
- services.hyprsunset.enable now follows config.nomarchy.toggles.
nightlight — symmetric with services.hypridle.enable ← toggles.idle.
Disabled toggle = no process running.
- extraArgs always reads from config.nomarchy.nightlightTemperature.
Drops the 6500K neutralising fork; when off the unit just doesn't
start.
- nomarchy-toggle-nightlight flips the running systemd user unit via
`systemctl --user start/stop hyprsunset.service` for instant
feedback, reads nightlightTemperature from state.json for the
notify-send line, and writes .nightlight back to state.json so the
next rebuild realigns services.hyprsunset.enable.
`nix flake check --no-build` + `bash -n` clean.
22 lines
837 B
Nix
22 lines
837 B
Nix
{ config, lib, ... }:
|
|
|
|
# hyprsunset (the blue-light filter) is gated on `nomarchy.toggles.nightlight`
|
|
# so a disabled toggle means no process runs — symmetric with how
|
|
# `services.hypridle.enable` is wired off `toggles.idle`. The temperature
|
|
# comes from `nomarchy.nightlightTemperature`, evaluated at Nix-eval time
|
|
# and baked into `extraArgs`. The toggle script (themes/engine/scripts/
|
|
# nomarchy-toggle-nightlight) writes both the toggle and the same
|
|
# temperature value into state.json and flips the systemd unit for
|
|
# instant feedback; the next rebuild's HM activation realigns systemd
|
|
# with the persistent state.
|
|
|
|
{
|
|
services.hyprsunset = {
|
|
enable = lib.mkDefault config.nomarchy.toggles.nightlight;
|
|
extraArgs = lib.mkDefault [
|
|
"--temperature"
|
|
(toString config.nomarchy.nightlightTemperature)
|
|
];
|
|
};
|
|
}
|