summary refs log tree commit diff
path: root/pkgs/applications/networking/syncthing
diff options
context:
space:
mode:
authorPeter Hoeg <peter@speartail.com>2016-09-26 15:40:21 +0800
committerJörg Thalheim <joerg@higgsboson.tk>2016-10-19 21:20:57 +0200
commit1026bebee61a1664605cf58136164e47478bc2f3 (patch)
tree5637431b6ffbf71ea8e0fef698e7f56a42de04b6 /pkgs/applications/networking/syncthing
parentdac481d9991ef2de20c3c45772c8e5dbdaa581fa (diff)
downloadnixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.tar
nixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.tar.gz
nixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.tar.bz2
nixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.tar.lz
nixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.tar.xz
nixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.tar.zst
nixpkgs-1026bebee61a1664605cf58136164e47478bc2f3.zip
syncthing: use service files from upstream
Currently only for the user services as NixOS handles the named system
instances slightly differently.

syncthing and syncthing-inotify are done the same way.

There are 4 parts to this:

 1) Copy in the upstream unit files
 2) Make the nixos module use the definition from upstream
 3) Enable restarting of all instances (system and user) on resume
 4) Allow the traffic in the firewall on default ports if wanted

fixes #18973
Diffstat (limited to 'pkgs/applications/networking/syncthing')
-rw-r--r--pkgs/applications/networking/syncthing/default.nix19
-rw-r--r--pkgs/applications/networking/syncthing/inotify.nix21
2 files changed, 32 insertions, 8 deletions
diff --git a/pkgs/applications/networking/syncthing/default.nix b/pkgs/applications/networking/syncthing/default.nix
index 3d8733635ee..d7918b3b912 100644
--- a/pkgs/applications/networking/syncthing/default.nix
+++ b/pkgs/applications/networking/syncthing/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, go }:
+{ stdenv, lib, fetchFromGitHub, go, pkgs }:
 
 stdenv.mkDerivation rec {
   version = "0.14.8";
@@ -25,11 +25,24 @@ stdenv.mkDerivation rec {
   '';
 
   installPhase = ''
-    mkdir -p $out/bin
+    mkdir -p $out/bin $out/etc/systemd/{system,user}
+
     cp bin/* $out/bin
+  '' + lib.optionalString (stdenv.isLinux) ''
+    substitute etc/linux-systemd/system/syncthing-resume.service \
+               $out/etc/systemd/system/syncthing-resume.service \
+               --replace /usr/bin/pkill ${pkgs.procps}/bin/pkill
+
+    substitute etc/linux-systemd/system/syncthing@.service \
+               $out/etc/systemd/system/syncthing@.service \
+               --replace /usr/bin/syncthing $out/bin/syncthing
+
+    substitute etc/linux-systemd/user/syncthing.service \
+               $out/etc/systemd/user/syncthing.service \
+               --replace /usr/bin/syncthing $out/bin/syncthing
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = https://www.syncthing.net/;
     description = "Open Source Continuous File Synchronization";
     license = stdenv.lib.licenses.mpl20;
diff --git a/pkgs/applications/networking/syncthing/inotify.nix b/pkgs/applications/networking/syncthing/inotify.nix
index ea8d73cb863..f1343d4a67e 100644
--- a/pkgs/applications/networking/syncthing/inotify.nix
+++ b/pkgs/applications/networking/syncthing/inotify.nix
@@ -15,12 +15,23 @@ buildGoPackage rec {
 
   goDeps = ./inotify-deps.nix;
 
-  meta = {
+  postInstall = ''
+    mkdir -p $bin/etc/systemd/{system,user}
+
+    substitute $src/etc/linux-systemd/system/syncthing-inotify@.service \
+               $bin/etc/systemd/system/syncthing-inotify@.service \
+               --replace /usr/bin/syncthing-inotify $bin/bin/syncthing-inotify
+
+    substitute $src/etc/linux-systemd/user/syncthing-inotify.service \
+               $bin/etc/systemd/user/syncthing-inotify.service \
+               --replace /usr/bin/syncthing-inotify $bin/bin/syncthing-inotify
+  '';
+
+  meta = with stdenv.lib; {
     homepage = https://github.com/syncthing/syncthing-inotify;
     description = "File watcher intended for use with Syncthing";
-    license = stdenv.lib.licenses.mpl20;
-    maintainers = with stdenv.lib.maintainers; [ joko ];
-    platforms = with stdenv.lib.platforms; linux ++ freebsd ++ openbsd ++ netbsd;
+    license = licenses.mpl20;
+    maintainers = with maintainers; [ joko peterhoeg ];
+    platforms = platforms.unix;
   };
-
 }