Unverified Commit 458c0737 authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

neard: 0.18 -> 0.19-unstable-2024-07-02 (#337524)

parents b5b8b5da e972a34a
Loading
Loading
Loading
Loading
+61 −8
Original line number Diff line number Diff line
# neard service.
{ config, lib, pkgs, ... }:
{
  ###### interface
  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 = {
    services.neard = {
      enable = lib.mkEnableOption "neard, an NFC daemon";
          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 ];
+37 −34
Original line number Diff line number Diff line
{ 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/

    install -D -m644 src/main.conf $out/etc/neard/main.conf
  doCheck = true;

    # 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
  };
}