Skip to content

Commit 7e16b79

Browse files
authored
gotify-server{,.ui}: modernize; remove Go reference (#421071)
2 parents eca4eaf + 895138d commit 7e16b79

File tree

2 files changed

+36
-50
lines changed

2 files changed

+36
-50
lines changed

pkgs/by-name/go/gotify-server/package.nix

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,40 @@
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+
})
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,31 @@
11
{
2+
src,
3+
version,
24
stdenv,
3-
yarn,
4-
fixup-yarn-lock,
5+
yarnConfigHook,
6+
yarnBuildHook,
57
nodejs-slim,
68
fetchYarnDeps,
7-
gotify-server,
89
}:
910

10-
stdenv.mkDerivation rec {
11+
stdenv.mkDerivation (finalAttrs: {
1112
pname = "gotify-ui";
12-
inherit (gotify-server) version;
13+
inherit version;
1314

14-
src = gotify-server.src + "/ui";
15+
src = src + "/ui";
1516

16-
offlineCache = fetchYarnDeps {
17-
yarnLock = "${src}/yarn.lock";
17+
yarnOfflineCache = fetchYarnDeps {
18+
yarnLock = "${finalAttrs.src}/yarn.lock";
1819
hash = "sha256-ejHzo6NHCMlNiYePWvfMY9Blb58pj3UQ5PFI0V84flI=";
1920
};
2021

2122
nativeBuildInputs = [
22-
yarn
23-
fixup-yarn-lock
23+
yarnConfigHook
24+
yarnBuildHook
2425
nodejs-slim
2526
];
2627

27-
postPatch = ''
28-
export HOME=$NIX_BUILD_TOP/fake_home
29-
yarn config --offline set yarn-offline-mirror $offlineCache
30-
fixup-yarn-lock yarn.lock
31-
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
32-
patchShebangs node_modules/
33-
'';
34-
35-
buildPhase = ''
36-
runHook preBuild
37-
38-
export NODE_OPTIONS=--openssl-legacy-provider
39-
yarn --offline build
40-
41-
runHook postBuild
42-
'';
28+
env.NODE_OPTIONS = "--openssl-legacy-provider";
4329

4430
installPhase = ''
4531
runHook preInstall
@@ -48,4 +34,4 @@ stdenv.mkDerivation rec {
4834
4935
runHook postInstall
5036
'';
51-
}
37+
})

0 commit comments

Comments
 (0)