88 nix-update-script ,
99} :
1010
11- buildGoModule rec {
11+ buildGoModule ( finalAttrs : {
1212 pname = "gotify-server" ;
1313 version = "2.6.3" ;
1414
1515 src = fetchFromGitHub {
1616 owner = "gotify" ;
1717 repo = "server" ;
18- rev = "v${ version } " ;
18+ tag = "v${ finalAttrs . version } " ;
1919 hash = "sha256-9vIReA29dWf3QwUYEW8JhzF9o74JZqG4zGobgI+gIWE=" ;
2020 } ;
2121
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-
2822 vendorHash = "sha256-rs6EfnJT6Jgif2TR5u5Tp5/Ozn+4uhSapksyKFnQiCo=" ;
2923
24+ # No test
3025 doCheck = false ;
3126
3227 buildInputs = [
3328 sqlite
3429 ] ;
3530
36- ui = callPackage ./ui.nix { } ;
31+ ui = callPackage ./ui.nix { inherit ( finalAttrs ) src version ; } ;
3732
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
33+ # Use preConfigure instead of preBuild to keep goModules independent from ui
34+ preConfigure = ''
35+ cp -r ${ finalAttrs . ui } ui/build
4336 '' ;
4437
4538 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 { } ;
39+ updateScript = nix-update-script {
40+ extraArgs = [
41+ "--subpackage"
42+ "ui"
43+ ] ;
44+ } ;
5045 tests = {
5146 nixos = nixosTests . gotify-server ;
5247 } ;
@@ -56,16 +51,21 @@ buildGoModule rec {
5651 # produce binaries which panic when executed and are not interesting at all
5752 subPackages = [ "." ] ;
5853
54+ # Based on LD_FLAGS in upstream's .github/workflows/build.yml:
55+ # https://github.com/gotify/server/blob/v2.6.3/.github/workflows/build.yml#L33
5956 ldflags = [
60- "-X main.Version=${ version } "
57+ "-s"
58+ "-X main.Version=${ finalAttrs . version } "
6159 "-X main.Mode=prod"
60+ "-X main.Commit=refs/tags/v${ finalAttrs . version } "
61+ "-X main.BuildDate=unknown"
6262 ] ;
6363
64- meta = with lib ; {
64+ meta = {
6565 description = "Simple server for sending and receiving messages in real-time per WebSocket" ;
6666 homepage = "https://gotify.net" ;
67- license = licenses . mit ;
68- maintainers = with maintainers ; [ doronbehar ] ;
67+ license = lib . licenses . mit ;
68+ maintainers = with lib . maintainers ; [ doronbehar ] ;
6969 mainProgram = "server" ;
7070 } ;
71- }
71+ } )
0 commit comments