From e972a34acb84f2c594b999485edd5f7905560cc8 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 26 Aug 2024 20:14:59 +0200 Subject: [PATCH] nixos/neard: expose settings option --- nixos/modules/services/desktops/neard.nix | 69 ++++++++++++++++++++--- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/desktops/neard.nix b/nixos/modules/services/desktops/neard.nix index 5d67adc09870..21a69a34001f 100644 --- a/nixos/modules/services/desktops/neard.nix +++ b/nixos/modules/services/desktops/neard.nix @@ -1,16 +1,69 @@ -# neard service. -{ config, lib, pkgs, ... }: { - ###### interface - options = { - services.neard = { - enable = lib.mkEnableOption "neard, an NFC daemon"; + 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; - ###### implementation - config = lib.mkIf config.services.neard.enable { environment.systemPackages = [ pkgs.neard ]; services.dbus.packages = [ pkgs.neard ];