summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/desktops/neard.nix
blob: 56a7578c2434922fb4a2ba575a12b549349abc94 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  config,
  lib,
  pkgs,
  ...
}:

let
  inherit (lib)
    mkEnableOption
    mkIf
    mkOption
    types
    ;
  cfg = config.services.neard;
  format = pkgs.formats.ini { };
  configFile = format.generate "neard.conf" cfg.settings;
in
{
  options.services.neard = {
    enable = mkEnableOption "neard, an NFC daemon";

    settings = mkOption {
      type = types.submodule {
        freeformType = format.type;
        options = {
          General = {
            ConstantPoll = mkOption {
              type = types.bool;
              default = false;
              description = ''
                Enable constant polling. Constant polling will automatically trigger a new
                polling loop whenever a tag or a device is no longer in the RF field.
              '';
            };

            DefaultPowered = mkOption {
              type = types.bool;
              default = true;
              description = ''
                Automatically turn an adapter on when being discovered.
              '';
            };

            ResetOnError = mkOption {
              type = types.bool;
              default = true;
              description = ''
                Power cycle the adapter when getting a driver error from the kernel.
              '';
            };
          };
        };
      };
      default = { };
      description = ''
        Neard INI-style configuration file as a Nix attribute set.

        See the upstream [configuration file](https://github.com/linux-nfc/neard/blob/master/src/main.conf).
      '';
    };
  };

  config = mkIf cfg.enable {
    environment.etc."neard/main.conf".source = configFile;

    environment.systemPackages = [ pkgs.neard ];

    services.dbus.packages = [ pkgs.neard ];

    systemd.packages = [ pkgs.neard ];
  };
}