1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 versionCheckHook,
6 nix-update-script,
7}:
8
9buildGoModule (finalAttrs: {
10 pname = "bark-server";
11 version = "2.2.5";
12
13 src = fetchFromGitHub {
14 owner = "Finb";
15 repo = "bark-server";
16 tag = "v${finalAttrs.version}";
17 hash = "sha256-Fe0PXwwVCrvoMTYMoTUkQaT6kVDdGPadFLkTDRhlh5U=";
18 # populate values that require us to use git. By doing this in postFetch we
19 # can delete .git afterwards and maintain better reproducibility of the src.
20 leaveDotGit = true;
21 postFetch = ''
22 cd "$out"
23 git rev-parse HEAD > $out/COMMIT
24 # '0000-00-00T00:00:00Z'
25 date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH
26 find "$out" -name .git -print0 | xargs -0 rm -rf
27 '';
28 };
29
30 vendorHash = "sha256-lpRxwCF+3+32FSn5XQ551l2ONtyuA9ewDQgwHgYUnT0=";
31
32 ldflags = [
33 "-s"
34 "-w"
35 "-X main.version=${finalAttrs.version}"
36 ];
37
38 preBuild = ''
39 ldflags+=" -X \"main.buildDate=$(<SOURCE_DATE_EPOCH)\""
40 ldflags+=" -X main.commitID==$(<COMMIT)"
41 '';
42
43 # All tests require network
44 doCheck = false;
45
46 doInstallCheck = true;
47
48 versionCheckProgramArg = "-v";
49
50 nativeInstallCheckInputs = [
51 versionCheckHook
52 ];
53
54 passthru.updateScript = nix-update-script { };
55
56 meta = {
57 description = "Backend of Bark, an iOS App which allows you to push customed notifications to your iPhone";
58 homepage = "https://github.com/Finb/bark-server";
59 changelog = "https://github.com/Finb/bark-server/releases/tag/v${finalAttrs.version}";
60 license = lib.licenses.mit;
61 maintainers = with lib.maintainers; [ moraxyc ];
62 mainProgram = "bark-server";
63 };
64})