nixpkgs/pkgs/servers/gotify/default.nix
Maximilian Bosch 4a559f8fee
gotify-server: fix UI
In version 2.0.15 `gotify` switched to `packr` at 2.x which is why the
UI can't be served properly via HTTP and causes an empty 500 response and
the following errors in `journald`:

```
2020/09/12 19:18:33 [Recovery] 2020/09/12 - 19:18:33 panic recovered:
GET / HTTP/1.1
Host: localhost:8080
Accept: */*
User-Agent: curl/7.72.0

stat /home/ma27/Projects/ui/build/index.html: no such file or directory
```

This wasn't caught by the VM-test as it only tested the REST and push
APIs. Using their internal `packr.go` script in our build as it's the
case in the upstream build-system[1] fixes the issue.

[1] https://github.com/gotify/server/pull/277/files#diff-b67911656ef5d18c4ae36cb6741b7965R48
2020-09-12 19:30:17 +02:00

60 lines
1.3 KiB
Nix

{ stdenv
, buildGoPackage
, lib
, fetchFromGitHub
, buildGoModule
, sqlite
, callPackage
}:
buildGoModule rec {
pname = "gotify-server";
# should be update just like all other files imported like that via the
# `update.sh` script.
version = import ./version.nix;
src = fetchFromGitHub {
owner = "gotify";
repo = "server";
rev = "v${version}";
sha256 = import ./source-sha.nix;
};
vendorSha256 = import ./vendor-sha.nix;
doCheck = false;
postPatch = ''
substituteInPlace app.go \
--replace 'Version = "unknown"' 'Version = "${version}"'
'';
buildInputs = [ sqlite ];
ui = callPackage ./ui.nix { };
preBuild = ''
cp -r ${ui}/libexec/gotify-ui/deps/gotify-ui/build ui/build && go run hack/packr/packr.go
'';
passthru = {
updateScript = ./update.sh;
};
# Otherwise, all other subpackages are built as well and from some reason,
# produce binaries which panic when executed and are not interesting at all
subPackages = [ "." ];
buildFlagsArray = [
"-ldflags='-X main.Version=${version} -X main.Mode=prod'"
];
meta = with stdenv.lib; {
description = "A simple server for sending and receiving messages in real-time per WebSocket";
homepage = "https://gotify.net";
license = licenses.mit;
maintainers = with maintainers; [ doronbehar ];
};
}