3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/servers/gotify/default.nix
Maximilian Bosch c55af95e8f
gotify-server: fix UI delivery
After bisecting `nixpkgs-master` I realized that the usage of
`-trimpath`[0] by default for Go modules[1] is responsible for breaking UI
delivery of `gotify-server`[2].

This behavior can only be turned off by setting `allowGoReference` to
`true`.

We may want to find a better long-term fix, but given that this only
affects a leaf-package and actually fixes the problem, this is good
enough for now.

Fixes #105472

[0] https://golang.org/doc/go1.13#go-command
[1] 4e9f7bbf85
[2] https://hydra.nixos.org/build/131660876
2020-11-30 23:00:18 +01:00

61 lines
1.5 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;
};
# With `allowGoReference = true;`, `buildGoModule` adds the `-trimpath`
# argument for Go builds which apparently breaks the UI like this:
#
# server[780]: stat /var/lib/private/ui/build/index.html: no such file or directory
allowGoReference = true;
vendorSha256 = import ./vendor-sha.nix;
doCheck = false;
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 ];
};
}