1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 inherit (lib)
10 mkEnableOption
11 mkIf
12 mkOption
13 types
14 ;
15 cfg = config.services.neard;
16 format = pkgs.formats.ini { };
17 configFile = format.generate "neard.conf" cfg.settings;
18in
19{
20 options.services.neard = {
21 enable = mkEnableOption "neard, an NFC daemon";
22
23 settings = mkOption {
24 type = types.submodule {
25 freeformType = format.type;
26 options = {
27 General = {
28 ConstantPoll = mkOption {
29 type = types.bool;
30 default = false;
31 description = ''
32 Enable constant polling. Constant polling will automatically trigger a new
33 polling loop whenever a tag or a device is no longer in the RF field.
34 '';
35 };
36
37 DefaultPowered = mkOption {
38 type = types.bool;
39 default = true;
40 description = ''
41 Automatically turn an adapter on when being discovered.
42 '';
43 };
44
45 ResetOnError = mkOption {
46 type = types.bool;
47 default = true;
48 description = ''
49 Power cycle the adapter when getting a driver error from the kernel.
50 '';
51 };
52 };
53 };
54 };
55 default = { };
56 description = ''
57 Neard INI-style configuration file as a Nix attribute set.
58
59 See the upstream [configuration file](https://github.com/linux-nfc/neard/blob/master/src/main.conf).
60 '';
61 };
62 };
63
64 config = mkIf cfg.enable {
65 environment.etc."neard/main.conf".source = configFile;
66
67 environment.systemPackages = [ pkgs.neard ];
68
69 services.dbus.packages = [ pkgs.neard ];
70
71 systemd.packages = [ pkgs.neard ];
72 };
73}