From 8e41532432774f9358d1e6e8b2e3939556e4097c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 13 Jul 2024 14:09:47 -0400 Subject: [PATCH] nixos/geoclue2: add package option Cannot use mkPackageOption as it does not support passing `apply`. --- nixos/modules/services/desktops/geoclue2.nix | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/desktops/geoclue2.nix b/nixos/modules/services/desktops/geoclue2.nix index 72a26933b222..2e5de34bb76f 100644 --- a/nixos/modules/services/desktops/geoclue2.nix +++ b/nixos/modules/services/desktops/geoclue2.nix @@ -5,9 +5,6 @@ with lib; let - # the demo agent isn't built by default, but we need it here - package = pkgs.geoclue2.override { withDemoAgent = config.services.geoclue2.enableDemoAgent; }; - cfg = config.services.geoclue2; defaultWhitelist = [ "gnome-shell" "io.elementary.desktop.agent-geoclue2" ]; @@ -132,6 +129,17 @@ in ''; }; + package = mkOption { + type = types.package; + default = pkgs.geoclue2; + defaultText = literalExpression "pkgs.geoclue2"; + apply = pkg: pkg.override { + # the demo agent isn't built by default, but we need it here + withDemoAgent = cfg.enableDemoAgent; + }; + description = "The geoclue2 package to use"; + }; + submitData = mkOption { type = types.bool; default = false; @@ -180,11 +188,11 @@ in ###### implementation config = mkIf cfg.enable { - environment.systemPackages = [ package ]; + environment.systemPackages = [ cfg.package ]; - services.dbus.packages = [ package ]; + services.dbus.packages = [ cfg.package ]; - systemd.packages = [ package ]; + systemd.packages = [ cfg.package ]; # we cannot use DynamicUser as we need the the geoclue user to exist for the # dbus policy to work @@ -223,7 +231,7 @@ in unitConfig.ConditionUser = "!@system"; serviceConfig = { Type = "exec"; - ExecStart = "${package}/libexec/geoclue-2.0/demos/agent"; + ExecStart = "${cfg.package}/libexec/geoclue-2.0/demos/agent"; Restart = "on-failure"; PrivateTmp = true; };