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/hostwip/yesman
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,57 +1,103 @@ |
||||
{ stdenv, lib, fetchFromGitHub, go, procps, removeReferencesTo }: |
||||
{ stdenv, lib, go, procps, removeReferencesTo, fetchFromGitHub }: |
||||
|
||||
stdenv.mkDerivation rec { |
||||
version = "0.14.44"; |
||||
name = "syncthing-${version}"; |
||||
let |
||||
common = { stname, target, patches ? [], postInstall ? "" }: |
||||
stdenv.mkDerivation rec { |
||||
version = "0.14.44"; |
||||
name = "${stname}-${version}"; |
||||
|
||||
src = fetchFromGitHub { |
||||
owner = "syncthing"; |
||||
repo = "syncthing"; |
||||
rev = "v${version}"; |
||||
sha256 = "1gdkx6lbzmdz2hqc9slbq41rwgkxmdisnj0iywx4mppmc2b4v6wh"; |
||||
}; |
||||
src = fetchFromGitHub { |
||||
owner = "syncthing"; |
||||
repo = "syncthing"; |
||||
rev = "v${version}"; |
||||
sha256 = "1gdkx6lbzmdz2hqc9slbq41rwgkxmdisnj0iywx4mppmc2b4v6wh"; |
||||
}; |
||||
|
||||
inherit patches; |
||||
|
||||
buildInputs = [ go ]; |
||||
nativeBuildInputs = [ removeReferencesTo ]; |
||||
|
||||
buildPhase = '' |
||||
# Syncthing expects that it is checked out in $GOPATH, if that variable is |
||||
# set. Since this isn't true when we're fetching source, we can explicitly |
||||
# 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} |
||||
''; |
||||
|
||||
installPhase = '' |
||||
install -Dm755 ${target} $out/bin/${target} |
||||
runHook postInstall |
||||
''; |
||||
|
||||
inherit postInstall; |
||||
|
||||
buildInputs = [ go removeReferencesTo ]; |
||||
preFixup = '' |
||||
find $out/bin -type f -exec remove-references-to -t ${go} '{}' '+' |
||||
''; |
||||
|
||||
buildPhase = '' |
||||
mkdir -p src/github.com/syncthing |
||||
ln -s $(pwd) src/github.com/syncthing/syncthing |
||||
export GOPATH=$(pwd) |
||||
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; |
||||
}; |
||||
}; |
||||
|
||||
# Syncthing's build.go script expects this working directory |
||||
cd src/github.com/syncthing/syncthing |
||||
in { |
||||
syncthing = common { |
||||
stname = "syncthing"; |
||||
target = "syncthing"; |
||||
|
||||
go run build.go -no-upgrade -version v${version} build |
||||
''; |
||||
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 |
||||
|
||||
installPhase = '' |
||||
mkdir -p $out/lib/systemd/{system,user} |
||||
'' + lib.optionalString (stdenv.isLinux) '' |
||||
mkdir -p $out/lib/systemd/{system,user} |
||||
|
||||
install -Dm755 syncthing $out/bin/syncthing |
||||
substitute etc/linux-systemd/system/syncthing-resume.service \ |
||||
$out/lib/systemd/system/syncthing-resume.service \ |
||||
--replace /usr/bin/pkill ${procps}/bin/pkill |
||||
|
||||
'' + lib.optionalString (stdenv.isLinux) '' |
||||
substitute etc/linux-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 \ |
||||
$out/lib/systemd/system/syncthing@.service \ |
||||
--replace /usr/bin/syncthing $out/bin/syncthing |
||||
|
||||
substitute etc/linux-systemd/system/syncthing@.service \ |
||||
$out/lib/systemd/system/syncthing@.service \ |
||||
--replace /usr/bin/syncthing $out/bin/syncthing |
||||
substitute etc/linux-systemd/user/syncthing.service \ |
||||
$out/lib/systemd/user/syncthing.service \ |
||||
--replace /usr/bin/syncthing $out/bin/syncthing |
||||
''; |
||||
}; |
||||
|
||||
syncthing-cli = common { |
||||
stname = "syncthing-cli"; |
||||
|
||||
patches = [ ./add-stcli-target.patch ]; |
||||
target = "stcli"; |
||||
}; |
||||
|
||||
syncthing-discovery = common { |
||||
stname = "syncthing-discovery"; |
||||
target = "stdiscosrv"; |
||||
}; |
||||
|
||||
substitute etc/linux-systemd/user/syncthing.service \ |
||||
$out/lib/systemd/user/syncthing.service \ |
||||
--replace /usr/bin/syncthing $out/bin/syncthing |
||||
''; |
||||
syncthing-relay = common { |
||||
stname = "syncthing-relay"; |
||||
target = "strelaysrv"; |
||||
|
||||
preFixup = '' |
||||
find $out/bin -type f -exec remove-references-to -t ${go} '{}' '+' |
||||
''; |
||||
postInstall = lib.optionalString (stdenv.isLinux) '' |
||||
mkdir -p $out/lib/systemd/system |
||||
|
||||
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; |
||||
substitute cmd/strelaysrv/etc/linux-systemd/strelaysrv.service \ |
||||
$out/lib/systemd/system/strelaysrv.service \ |
||||
--replace /usr/bin/strelaysrv $out/bin/strelaysrv |
||||
''; |
||||
}; |
||||
} |
||||
|
Loading…
Reference in new issue