Skip to content

Instantly share code, notes, and snippets.

@Lassulus
Created August 10, 2019 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lassulus/fc2cc45fc5caffa4e76885644c26e0fb to your computer and use it in GitHub Desktop.
Save Lassulus/fc2cc45fc5caffa4e76885644c26e0fb to your computer and use it in GitHub Desktop.
-{ 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
'';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment