From 71d72af36cd12eb9264223f95b3bb125512d4d32 Mon Sep 17 00:00:00 2001 From: Myned Date: Sat, 21 Dec 2024 13:45:02 -0500 Subject: [PATCH] geoclue2: add static option Signed-off-by: Myned --- options/custom/services/default.nix | 2 +- options/custom/services/geoclue2.nix | 35 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/options/custom/services/default.nix b/options/custom/services/default.nix index 2caa3be..355bb9b 100644 --- a/options/custom/services/default.nix +++ b/options/custom/services/default.nix @@ -8,6 +8,7 @@ with lib; { (mkIf config.custom.default { #// automatic-timezoned.enable = true; #// agenix.enable = true; + geoclue2.enable = true; #// netbird.enable = true; tailscale.enable = true; tzupdate.enable = true; @@ -17,7 +18,6 @@ with lib; { dbus.enable = true; flatpak.enable = true; fwupd.enable = true; - geoclue2.enable = true; #// kdeconnect.enable = true; libinput.enable = true; logind.enable = true; diff --git a/options/custom/services/geoclue2.nix b/options/custom/services/geoclue2.nix index 78836eb..2e02185 100644 --- a/options/custom/services/geoclue2.nix +++ b/options/custom/services/geoclue2.nix @@ -7,7 +7,10 @@ with lib; let cfg = config.custom.services.geoclue2; in { - options.custom.services.geoclue2.enable = mkOption {default = false;}; + options.custom.services.geoclue2 = { + enable = mkOption {default = false;}; + static = mkOption {default = true;}; + }; config = mkIf cfg.enable { age.secrets = let @@ -17,28 +20,30 @@ in { group = "geoclue"; }; in { - "common/geoclue2/geolocation" = secret "common/geoclue2/geolocation"; + "common/geoclue2/geolocation" = mkIf cfg.static (secret "common/geoclue2/geolocation"); }; # https://gitlab.freedesktop.org/geoclue/geoclue # FIXME: geoclue2 relies on MLS, which is retired # https://github.com/NixOS/nixpkgs/issues/321121 - # TODO: Use static source option when merged into unstable - # https://github.com/NixOS/nixpkgs/pull/329654 - services.geoclue2 = { - enable = true; - - # Overriden by static source - enable3G = false; - enableCDMA = false; - enableModemGPS = false; - enableNmea = false; - enableWifi = false; - }; + services.geoclue2 = + { + enable = true; + } + // optionalAttrs cfg.static { + # TODO: Use static source option when merged into unstable + # https://github.com/NixOS/nixpkgs/pull/329654 + # Overriden by static source + enable3G = false; + enableCDMA = false; + enableModemGPS = false; + enableNmea = false; + enableWifi = false; + }; # Manually use static source from coordinates # https://github.com/NixOS/nixpkgs/issues/311595#issuecomment-2247989491 - environment.etc = { + environment.etc = mkIf cfg.static { "geolocation".source = config.age.secrets."common/geoclue2/geolocation".path; "geoclue/conf.d/00-config.conf".text = ''