From 3591d639b181b2058ade27c1dbb01ffe023ba57f Mon Sep 17 00:00:00 2001 From: andre4ik3 Date: Thu, 24 Oct 2024 05:42:31 +0400 Subject: [PATCH] nqptp: copy systemd service and add capability The binary has its capability to listen on ports removed, and upstream has already moved to AmbientCapabilities in the systemd service instead of using setcap. Copying the systemd service allows using the package with `systemd.packages`. The patch should be removed after version 1.2.4, along with the other patch. The patch is taken from [commit 050a8c2][1] in the upstream repository. [1]: https://github.com/mikebrady/nqptp/commit/050a8c2de9f3e1f4859abf9b36d2f18afd4c34d7 --- pkgs/tools/networking/nqptp/default.nix | 8 +++++++- .../nqptp/systemd-service-capability.patch | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/networking/nqptp/systemd-service-capability.patch diff --git a/pkgs/tools/networking/nqptp/default.nix b/pkgs/tools/networking/nqptp/default.nix index 26aec487789d..e045c3fe4237 100644 --- a/pkgs/tools/networking/nqptp/default.nix +++ b/pkgs/tools/networking/nqptp/default.nix @@ -18,8 +18,9 @@ stdenv.mkDerivation rec { }; patches = [ - # this patch should be removed when > 1.2.4 + # these patches should be removed when > 1.2.4 ./remove-setcap.patch + ./systemd-service-capability.patch ]; nativeBuildInputs = [ autoreconfHook pkg-config ]; @@ -28,6 +29,11 @@ stdenv.mkDerivation rec { ignoredVersions = ".*(-dev|d0)"; }; + postInstall = '' + mkdir -p $out/lib/systemd/system + cp nqptp.service $out/lib/systemd/system + ''; + meta = { homepage = "https://github.com/mikebrady/nqptp"; description = "Daemon and companion application to Shairport Sync that monitors timing data from any PTP clocks"; diff --git a/pkgs/tools/networking/nqptp/systemd-service-capability.patch b/pkgs/tools/networking/nqptp/systemd-service-capability.patch new file mode 100644 index 000000000000..e06a52fe1c68 --- /dev/null +++ b/pkgs/tools/networking/nqptp/systemd-service-capability.patch @@ -0,0 +1,12 @@ +diff --git a/nqptp.service.in b/nqptp.service.in +index 6f1eb0c..53e6a2e 100644 +--- a/nqptp.service.in ++++ b/nqptp.service.in +@@ -8,6 +8,7 @@ Before=shairport-sync.service + ExecStart=@prefix@/bin/nqptp + User=nqptp + Group=nqptp ++AmbientCapabilities=CAP_NET_BIND_SERVICE + + [Install] + WantedBy=multi-user.target