syncthing: clean up package

Thank you, @Lassulus
This commit is contained in:
Emmanuel Rosa
2019-08-11 08:35:24 +07:00
parent d80670bdc2
commit fd39791936
2 changed files with 11 additions and 792 deletions
@@ -1,8 +1,8 @@
{ buildGoPackage, stdenv, lib, procps, fetchFromGitHub }:
{ buildGoModule, stdenv, lib, procps, fetchFromGitHub }:
let
common = { stname, target, postInstall ? "" }:
buildGoPackage rec {
buildGoModule rec {
version = "1.2.1";
name = "${stname}-${version}";
@@ -15,7 +15,7 @@ let
goPackagePath = "github.com/syncthing/syncthing";
goDeps = ./deps.nix;
modSha256 = "1daixrpdj97ck02853hwp8l158sja5a7a37h0gdbwb1lgf5hsn05";
patches = [
./add-stcli-target.patch
@@ -25,18 +25,14 @@ let
buildPhase = ''
runHook preBuild
pushd go/src/${goPackagePath}
go run build.go -no-upgrade -version v${version} build ${target}
popd
runHook postBuild
'';
installPhase = ''
pushd go/src/${goPackagePath}
runHook preInstall
install -Dm755 ${target} $bin/bin/${target}
install -Dm755 ${target} $out/bin/${target}
runHook postInstall
popd
'';
inherit postInstall;
@@ -65,19 +61,19 @@ in {
done
'' + lib.optionalString (stdenv.isLinux) ''
mkdir -p $bin/lib/systemd/{system,user}
mkdir -p $out/lib/systemd/{system,user}
substitute etc/linux-systemd/system/syncthing-resume.service \
$bin/lib/systemd/system/syncthing-resume.service \
$out/lib/systemd/system/syncthing-resume.service \
--replace /usr/bin/pkill ${procps}/bin/pkill
substitute etc/linux-systemd/system/syncthing@.service \
$bin/lib/systemd/system/syncthing@.service \
--replace /usr/bin/syncthing $bin/bin/syncthing
$out/lib/systemd/system/syncthing@.service \
--replace /usr/bin/syncthing $out/bin/syncthing
substitute etc/linux-systemd/user/syncthing.service \
$bin/lib/systemd/user/syncthing.service \
--replace /usr/bin/syncthing $bin/bin/syncthing
$out/lib/systemd/user/syncthing.service \
--replace /usr/bin/syncthing $out/bin/syncthing
'';
};
@@ -101,7 +97,7 @@ in {
substitute cmd/strelaysrv/etc/linux-systemd/strelaysrv.service \
$out/lib/systemd/system/strelaysrv.service \
--replace /usr/bin/strelaysrv $bin/bin/strelaysrv
--replace /usr/bin/strelaysrv $out/bin/strelaysrv
'';
};
}