about summary refs log tree commit diff
path: root/nixos/modules/programs/mepo.nix
blob: 783d2ad14962667758e9f5cbbddbeaf7e6479c5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ pkgs, config, lib, ...}:
let
  cfg = config.programs.mepo;
in
{
  options.programs.mepo = {
    enable = lib.mkEnableOption "Mepo, a fast, simple and hackable OSM map viewer";

    locationBackends = {
      gpsd = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description = ''
          Whether to enable location detection via gpsd.
          This may require additional configuration of gpsd, see [here](#opt-services.gpsd.enable)
        '';
      };

      geoclue = lib.mkOption {
        type = lib.types.bool;
        default = true;
        description = "Whether to enable location detection via geoclue";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = with pkgs; [
      mepo
    ] ++ lib.optional cfg.locationBackends.geoclue geoclue2-with-demo-agent
    ++ lib.optional cfg.locationBackends.gpsd gpsd;

    services.geoclue2 = lib.mkIf cfg.locationBackends.geoclue {
      enable = true;
      appConfig.where-am-i = {
        isAllowed = true;
        isSystem = false;
      };
    };

    services.gpsd.enable = cfg.locationBackends.gpsd;
  };

  meta.maintainers = with lib.maintainers; [ laalsaas ];
}