feat(nightlight): geo mode — lat/long-computed sunset via wlsunset
All checks were successful
Check / eval (push) Successful in 4m20s
All checks were successful
Check / eval (push) Successful in 4m20s
Set BOTH nomarchy.nightlight.latitude/.longitude and the night light switches backing unit: wlsunset computes sunrise/sunset from the location daily (the fixed .sunrise/.sunset are ignored; .temperature feeds the night temp). Everything user-facing is unchanged — same nomarchy-nightlight toggle script, Waybar moon, and live-state ExecCondition gate; the unit name is a single let-binding so all three follow together. Declarative-only on purpose: coordinates are machine config like the keyboard layout, so home.nix (commented template example), not a menu writer. checks.nightlight-geo guards the wiring at pure eval: rendered wlsunset ExecStart carries the coords + night temperature, the ExecCondition gate landed on the swapped unit, hyprsunset stays off in geo mode. Verification: V1 — nix flake check --no-build exit 0 (evals the new asserts + option-docs sync); built downstream-template-home (default hyprsunset path unregressed). V3 pending: visible warm shift at the location's night + instant toggle/off-persistence on the swapped unit (HARDWARE-QUEUE § Any machine). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
# schedule (temperature/sunrise/sunset) is tuned via nomarchy.nightlight.* in
|
||||
# home.nix and baked into the unit's time-based `profile`.
|
||||
#
|
||||
# Geo mode: when BOTH nomarchy.nightlight.latitude and .longitude are set,
|
||||
# wlsunset replaces hyprsunset — it computes sunrise/sunset from the
|
||||
# location itself (the fixed .sunrise/.sunset times are ignored). Same
|
||||
# toggle script, same Waybar moon, same live-state ExecCondition gate;
|
||||
# only the unit underneath changes.
|
||||
#
|
||||
# Off by default and opt-in. Two git-tracked flags in the state file, both
|
||||
# menu-written (no ~/.local/state):
|
||||
# settings.nightlight.installed — does the hyprsunset unit exist? Sticky; the
|
||||
@@ -18,12 +24,15 @@ let
|
||||
cfg = config.nomarchy.nightlight;
|
||||
s = config.nomarchy.settings.nightlight;
|
||||
sync = lib.getExe config.nomarchy.package;
|
||||
# Geo mode flips the backing unit; everything user-facing stays the same.
|
||||
geo = cfg.latitude != null && cfg.longitude != null;
|
||||
unit = if geo then "wlsunset.service" else "hyprsunset.service";
|
||||
# Runtime-on default for when the `on` key hasn't been written yet (e.g. right
|
||||
# after the first enable). Baked at eval; only used when the live key is absent.
|
||||
onDefault = lib.boolToString s.on;
|
||||
|
||||
nomarchy-nightlight = pkgs.writeShellScriptBin "nomarchy-nightlight" ''
|
||||
unit=hyprsunset.service
|
||||
unit=${unit}
|
||||
# Instant runtime on/off: write the in-flake state WITHOUT a rebuild.
|
||||
write_on() { ${sync} --quiet set settings.nightlight.on "$1" --no-switch; }
|
||||
# First enable: mark the feature installed and REBUILD to create the unit
|
||||
@@ -69,7 +78,7 @@ in
|
||||
# home.nix also works as a declarative opt-in.
|
||||
nomarchy.nightlight.enable = lib.mkDefault s.installed;
|
||||
|
||||
services.hyprsunset = lib.mkIf cfg.enable {
|
||||
services.hyprsunset = lib.mkIf (cfg.enable && !geo) {
|
||||
enable = true;
|
||||
settings.profile = [
|
||||
# Daytime: identity = no colour change.
|
||||
@@ -79,10 +88,19 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
# Geo mode: wlsunset owns the schedule — it recomputes sunrise/sunset
|
||||
# from the coordinates daily (no fixed profile to bake).
|
||||
services.wlsunset = lib.mkIf (cfg.enable && geo) {
|
||||
enable = true;
|
||||
latitude = cfg.latitude;
|
||||
longitude = cfg.longitude;
|
||||
temperature.night = cfg.temperature;
|
||||
};
|
||||
|
||||
# Gate the unit on the LIVE on/off state at start time (login/reboot), not
|
||||
# at eval time — so a menu toggle (written without a rebuild) is honoured on
|
||||
# the next session. A failed condition skips the unit (inactive, not failed).
|
||||
systemd.user.services.hyprsunset.Service.ExecCondition =
|
||||
systemd.user.services.${lib.removeSuffix ".service" unit}.Service.ExecCondition =
|
||||
lib.mkIf cfg.enable "${nomarchy-nightlight}/bin/nomarchy-nightlight should-start";
|
||||
|
||||
home.packages = [ nomarchy-nightlight ];
|
||||
|
||||
Reference in New Issue
Block a user