1{ lib
2, buildGoPackage
3, fetchFromGitHub
4, buildGoModule
5, sqlite
6, callPackage
7, nixosTests
8, nix-update-script
9}:
10
11buildGoModule rec {
12 pname = "gotify-server";
13 version = "2.3.0";
14
15 src = fetchFromGitHub {
16 owner = "gotify";
17 repo = "server";
18 rev = "v${version}";
19 hash = "sha256-fWcdnmpLZycg7hmPNnphGcuSMTI4bsq57XPoSyQSGDA=";
20 };
21
22 # With `allowGoReference = true;`, `buildGoModule` adds the `-trimpath`
23 # argument for Go builds which apparently breaks the UI like this:
24 #
25 # server[780]: stat /var/lib/private/ui/build/index.html: no such file or directory
26 allowGoReference = true;
27
28 vendorHash = "sha256-im7Pauit0tWi0BcyKtxybOqsu7rrIHZwY5Olta3nJJI=";
29
30 doCheck = false;
31
32 buildInputs = [
33 sqlite
34 ];
35
36 ui = callPackage ./ui.nix { };
37
38 preBuild = ''
39 if [ -n "$ui" ] # to make the preBuild a no-op inside the goModules fixed-output derivation, where it would fail
40 then
41 cp -r $ui ui/build
42 fi
43 '';
44
45 passthru = {
46 # For nix-update to detect the location of this attribute from this
47 # derivation.
48 inherit (ui) offlineCache;
49 updateScript = nix-update-script { };
50 tests = {
51 nixos = nixosTests.gotify-server;
52 };
53 };
54
55 # Otherwise, all other subpackages are built as well and from some reason,
56 # produce binaries which panic when executed and are not interesting at all
57 subPackages = [ "." ];
58
59 ldflags = [
60 "-X main.Version=${version}" "-X main.Mode=prod"
61 ];
62
63 meta = with lib; {
64 description = "A simple server for sending and receiving messages in real-time per WebSocket";
65 homepage = "https://gotify.net";
66 license = licenses.mit;
67 maintainers = with maintainers; [ doronbehar ];
68 mainProgram = "server";
69 };
70}