2024-09-09 00:22:14 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-13 01:50:53 +00:00
|
|
|
with lib; let
|
2024-09-09 00:22:14 +00:00
|
|
|
cfg = config.custom.services.geoclue2;
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
2024-12-21 18:45:02 +00:00
|
|
|
options.custom.services.geoclue2 = {
|
|
|
|
enable = mkOption {default = false;};
|
|
|
|
static = mkOption {default = true;};
|
|
|
|
};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-09-13 01:50:53 +00:00
|
|
|
age.secrets = let
|
|
|
|
secret = filename: {
|
|
|
|
file = "${inputs.self}/secrets/${filename}";
|
|
|
|
owner = "geoclue";
|
|
|
|
group = "geoclue";
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
2024-12-21 18:45:02 +00:00
|
|
|
"common/geoclue2/geolocation" = mkIf cfg.static (secret "common/geoclue2/geolocation");
|
2024-09-13 01:50:53 +00:00
|
|
|
};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
# https://gitlab.freedesktop.org/geoclue/geoclue
|
|
|
|
# FIXME: geoclue2 relies on MLS, which is retired
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/321121
|
2024-12-21 18:45:02 +00:00
|
|
|
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;
|
|
|
|
};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
# Manually use static source from coordinates
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/311595#issuecomment-2247989491
|
2024-12-21 18:45:02 +00:00
|
|
|
environment.etc = mkIf cfg.static {
|
2024-09-18 13:49:10 +00:00
|
|
|
"geolocation".source = config.age.secrets."common/geoclue2/geolocation".path;
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
"geoclue/conf.d/00-config.conf".text = ''
|
|
|
|
[static-source]
|
|
|
|
enable=true
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|