syncthing: Add discovery/relay servers, improve build (#34831)
- Fix GOPATH checks - Install manpages - Also build and install discovery and relay servers + cli - Make the build more pure by explicitly setting the build username/host
This commit is contained in:
parent
a956c646fb
commit
394a8818e4
@ -0,0 +1,17 @@
|
|||||||
|
diff --git i/build.go w/build.go
|
||||||
|
index 7d400d6f..1b5e1d25 100644
|
||||||
|
--- i/build.go
|
||||||
|
+++ w/build.go
|
||||||
|
@@ -175,6 +175,12 @@ var targets = map[string]target{
|
||||||
|
{src: "AUTHORS", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/AUTHORS.txt", perm: 0644},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
+ "stcli": {
|
||||||
|
+ name: "stcli",
|
||||||
|
+ description: "Syncthing CLI",
|
||||||
|
+ buildPkg: "github.com/syncthing/syncthing/cmd/stcli",
|
||||||
|
+ binaryName: "stcli", // .exe will be added automatically for Windows builds
|
||||||
|
+ },
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
@ -1,8 +1,10 @@
|
|||||||
{ stdenv, lib, fetchFromGitHub, go, procps, removeReferencesTo }:
|
{ stdenv, lib, go, procps, removeReferencesTo, fetchFromGitHub }:
|
||||||
|
|
||||||
|
let
|
||||||
|
common = { stname, target, patches ? [], postInstall ? "" }:
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
version = "0.14.44";
|
version = "0.14.44";
|
||||||
name = "syncthing-${version}";
|
name = "${stname}-${version}";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "syncthing";
|
owner = "syncthing";
|
||||||
@ -11,25 +13,55 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "1gdkx6lbzmdz2hqc9slbq41rwgkxmdisnj0iywx4mppmc2b4v6wh";
|
sha256 = "1gdkx6lbzmdz2hqc9slbq41rwgkxmdisnj0iywx4mppmc2b4v6wh";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [ go removeReferencesTo ];
|
inherit patches;
|
||||||
|
|
||||||
|
buildInputs = [ go ];
|
||||||
|
nativeBuildInputs = [ removeReferencesTo ];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
mkdir -p src/github.com/syncthing
|
# Syncthing expects that it is checked out in $GOPATH, if that variable is
|
||||||
ln -s $(pwd) src/github.com/syncthing/syncthing
|
# set. Since this isn't true when we're fetching source, we can explicitly
|
||||||
export GOPATH=$(pwd)
|
# unset it and force Syncthing to set up a temporary one for us.
|
||||||
|
env GOPATH= BUILD_USER=nix BUILD_HOST=nix go run build.go -no-upgrade -version v${version} build ${target}
|
||||||
# Syncthing's build.go script expects this working directory
|
|
||||||
cd src/github.com/syncthing/syncthing
|
|
||||||
|
|
||||||
go run build.go -no-upgrade -version v${version} build
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/lib/systemd/{system,user}
|
install -Dm755 ${target} $out/bin/${target}
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
install -Dm755 syncthing $out/bin/syncthing
|
inherit postInstall;
|
||||||
|
|
||||||
|
preFixup = ''
|
||||||
|
find $out/bin -type f -exec remove-references-to -t ${go} '{}' '+'
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = https://www.syncthing.net/;
|
||||||
|
description = "Open Source Continuous File Synchronization";
|
||||||
|
license = licenses.mpl20;
|
||||||
|
maintainers = with maintainers; [ pshendry joko peterhoeg andrew-d ];
|
||||||
|
platforms = platforms.unix;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
syncthing = common {
|
||||||
|
stname = "syncthing";
|
||||||
|
target = "syncthing";
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
# This installs man pages in the correct directory according to the suffix
|
||||||
|
# on the filename
|
||||||
|
for mf in man/*.[1-9]; do
|
||||||
|
mantype="$(echo "$mf" | awk -F"." '{print $NF}')"
|
||||||
|
mandir="$out/share/man/man$mantype"
|
||||||
|
install -Dm644 "$mf" "$mandir/$(basename "$mf")"
|
||||||
|
done
|
||||||
|
|
||||||
'' + lib.optionalString (stdenv.isLinux) ''
|
'' + lib.optionalString (stdenv.isLinux) ''
|
||||||
|
mkdir -p $out/lib/systemd/{system,user}
|
||||||
|
|
||||||
substitute etc/linux-systemd/system/syncthing-resume.service \
|
substitute etc/linux-systemd/system/syncthing-resume.service \
|
||||||
$out/lib/systemd/system/syncthing-resume.service \
|
$out/lib/systemd/system/syncthing-resume.service \
|
||||||
--replace /usr/bin/pkill ${procps}/bin/pkill
|
--replace /usr/bin/pkill ${procps}/bin/pkill
|
||||||
@ -42,16 +74,30 @@ stdenv.mkDerivation rec {
|
|||||||
$out/lib/systemd/user/syncthing.service \
|
$out/lib/systemd/user/syncthing.service \
|
||||||
--replace /usr/bin/syncthing $out/bin/syncthing
|
--replace /usr/bin/syncthing $out/bin/syncthing
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
preFixup = ''
|
syncthing-cli = common {
|
||||||
find $out/bin -type f -exec remove-references-to -t ${go} '{}' '+'
|
stname = "syncthing-cli";
|
||||||
|
|
||||||
|
patches = [ ./add-stcli-target.patch ];
|
||||||
|
target = "stcli";
|
||||||
|
};
|
||||||
|
|
||||||
|
syncthing-discovery = common {
|
||||||
|
stname = "syncthing-discovery";
|
||||||
|
target = "stdiscosrv";
|
||||||
|
};
|
||||||
|
|
||||||
|
syncthing-relay = common {
|
||||||
|
stname = "syncthing-relay";
|
||||||
|
target = "strelaysrv";
|
||||||
|
|
||||||
|
postInstall = lib.optionalString (stdenv.isLinux) ''
|
||||||
|
mkdir -p $out/lib/systemd/system
|
||||||
|
|
||||||
|
substitute cmd/strelaysrv/etc/linux-systemd/strelaysrv.service \
|
||||||
|
$out/lib/systemd/system/strelaysrv.service \
|
||||||
|
--replace /usr/bin/strelaysrv $out/bin/strelaysrv
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
|
||||||
homepage = https://www.syncthing.net/;
|
|
||||||
description = "Open Source Continuous File Synchronization";
|
|
||||||
license = licenses.mpl20;
|
|
||||||
maintainers = with maintainers; [ pshendry joko peterhoeg ];
|
|
||||||
platforms = platforms.unix;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -17352,7 +17352,11 @@ with pkgs;
|
|||||||
|
|
||||||
syncplay = callPackage ../applications/networking/syncplay { };
|
syncplay = callPackage ../applications/networking/syncplay { };
|
||||||
|
|
||||||
syncthing = callPackage ../applications/networking/syncthing { };
|
inherit (callPackages ../applications/networking/syncthing { })
|
||||||
|
syncthing
|
||||||
|
syncthing-cli
|
||||||
|
syncthing-discovery
|
||||||
|
syncthing-relay;
|
||||||
|
|
||||||
syncthing-gtk = python2Packages.callPackage ../applications/networking/syncthing-gtk { };
|
syncthing-gtk = python2Packages.callPackage ../applications/networking/syncthing-gtk { };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user