From 6986c2091f6ecde550279353f6847e7b5b1cfb58 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 26 Aug 2024 20:13:04 +0200 Subject: [PATCH 1/2] neard: 0.18 -> 0.19-unstable-2024-07-02 --- pkgs/servers/neard/default.nix | 71 ++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/pkgs/servers/neard/default.nix b/pkgs/servers/neard/default.nix index 12bfc319635e..d82043f2f5e0 100644 --- a/pkgs/servers/neard/default.nix +++ b/pkgs/servers/neard/default.nix @@ -1,69 +1,74 @@ { stdenv , lib -, fetchurl +, fetchFromGitHub , autoreconfHook , autoconf-archive +, gobject-introspection , pkg-config -, systemd +, wrapGAppsHook3 , glib , dbus , libnl -, python2Packages +, python3Packages }: -stdenv.mkDerivation rec { +stdenv.mkDerivation { pname = "neard"; - version = "0.18"; + version = "0.19-unstable-2024-07-02"; outputs = [ "out" "dev" ]; - src = fetchurl { - url = "https://git.kernel.org/pub/scm/network/nfc/neard.git/snapshot/neard-${version}.tar.gz"; - sha256 = "wBPjEVMV4uEdFrXw8cjOmvvNuiaACq2RJF/ZtKXck4s="; + src = fetchFromGitHub { + owner = "linux-nfc"; + repo = "neard"; + rev = "a0a7d4d677800a39346f0c89d93d0fe43a95efad"; + hash = "sha256-6BgX7cJwxX+1RX3wU+HY/PIBgzomzOKemnl0SDLJNro="; }; + postPatch = '' + patchShebangs test/* + ''; + nativeBuildInputs = [ autoreconfHook autoconf-archive + gobject-introspection pkg-config - python2Packages.wrapPython + python3Packages.wrapPython + wrapGAppsHook3 + ]; + + dontWrapGApps = true; + + configureFlags = [ + "--enable-pie" + "--enable-test" + "--enable-tools" + "--with-sysconfdir=/etc" + "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" + "--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user" ]; buildInputs = [ - systemd - glib dbus + glib libnl - ] ++ (with python2Packages; [ - python - ]); - - pythonPath = with python2Packages; [ - pygobject2 - dbus-python - pygtk ]; strictDeps = true; enableParallelBuilding = true; - configureFlags = [ - "--disable-debug" - "--enable-tools" - "--enable-ese" - "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" + pythonPath = with python3Packages; [ + pygobject3 + dbus-python ]; - postInstall = '' - install -m 0755 tools/snep-send $out/bin/ + doCheck = true; - install -D -m644 src/main.conf $out/etc/neard/main.conf - - # INFO: the config option "--enable-test" would copy the apps to $out/lib/neard/test/ instead - install -d $out/lib/neard - install -m 0755 test/* $out/lib/neard/ - wrapPythonProgramsIn $out/lib/neard "$out $pythonPath" + preFixup = '' + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") + wrapPythonProgramsIn "$out/lib/neard" "$pythonPath" ''; meta = with lib; { @@ -72,7 +77,5 @@ stdenv.mkDerivation rec { license = licenses.gpl2Only; maintainers = [ ]; platforms = platforms.unix; - # error: wcwidth-0.2.13 not supported for interpreter python2.7 - broken = true; # Added 2024-03-17 }; } From e972a34acb84f2c594b999485edd5f7905560cc8 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 26 Aug 2024 20:14:59 +0200 Subject: [PATCH 2/2] 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 ];