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
This commit is contained in:
Peter Hoeg
2016-10-19 21:20:57 +02:00
committed by Jörg Thalheim
parent dac481d999
commit 1026bebee6
3 changed files with 87 additions and 72 deletions
@@ -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;
@@ -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;
};
}