gotify-server{,.ui}: modernize; remove Go reference (#421071)

This commit is contained in:
Doron Behar
2025-07-01 10:42:01 +03:00
committed by GitHub
2 changed files with 36 additions and 50 deletions
+23 -23
View File
@@ -8,45 +8,40 @@
nix-update-script,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "gotify-server";
version = "2.6.3";
src = fetchFromGitHub {
owner = "gotify";
repo = "server";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-9vIReA29dWf3QwUYEW8JhzF9o74JZqG4zGobgI+gIWE=";
};
# 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;
vendorHash = "sha256-rs6EfnJT6Jgif2TR5u5Tp5/Ozn+4uhSapksyKFnQiCo=";
# No test
doCheck = false;
buildInputs = [
sqlite
];
ui = callPackage ./ui.nix { };
ui = callPackage ./ui.nix { inherit (finalAttrs) src version; };
preBuild = ''
if [ -n "$ui" ] # to make the preBuild a no-op inside the goModules fixed-output derivation, where it would fail
then
cp -r $ui ui/build
fi
# Use preConfigure instead of preBuild to keep goModules independent from ui
preConfigure = ''
cp -r ${finalAttrs.ui} ui/build
'';
passthru = {
# For nix-update to detect the location of this attribute from this
# derivation.
inherit (ui) offlineCache;
updateScript = nix-update-script { };
updateScript = nix-update-script {
extraArgs = [
"--subpackage"
"ui"
];
};
tests = {
nixos = nixosTests.gotify-server;
};
@@ -56,16 +51,21 @@ buildGoModule rec {
# produce binaries which panic when executed and are not interesting at all
subPackages = [ "." ];
# Based on LD_FLAGS in upstream's .github/workflows/build.yml:
# https://github.com/gotify/server/blob/v2.6.3/.github/workflows/build.yml#L33
ldflags = [
"-X main.Version=${version}"
"-s"
"-X main.Version=${finalAttrs.version}"
"-X main.Mode=prod"
"-X main.Commit=refs/tags/v${finalAttrs.version}"
"-X main.BuildDate=unknown"
];
meta = with lib; {
meta = {
description = "Simple server for sending and receiving messages in real-time per WebSocket";
homepage = "https://gotify.net";
license = licenses.mit;
maintainers = with maintainers; [ doronbehar ];
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ doronbehar ];
mainProgram = "server";
};
}
})
+13 -27
View File
@@ -1,45 +1,31 @@
{
src,
version,
stdenv,
yarn,
fixup-yarn-lock,
yarnConfigHook,
yarnBuildHook,
nodejs-slim,
fetchYarnDeps,
gotify-server,
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "gotify-ui";
inherit (gotify-server) version;
inherit version;
src = gotify-server.src + "/ui";
src = src + "/ui";
offlineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/yarn.lock";
hash = "sha256-ejHzo6NHCMlNiYePWvfMY9Blb58pj3UQ5PFI0V84flI=";
};
nativeBuildInputs = [
yarn
fixup-yarn-lock
yarnConfigHook
yarnBuildHook
nodejs-slim
];
postPatch = ''
export HOME=$NIX_BUILD_TOP/fake_home
yarn config --offline set yarn-offline-mirror $offlineCache
fixup-yarn-lock yarn.lock
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
'';
buildPhase = ''
runHook preBuild
export NODE_OPTIONS=--openssl-legacy-provider
yarn --offline build
runHook postBuild
'';
env.NODE_OPTIONS = "--openssl-legacy-provider";
installPhase = ''
runHook preInstall
@@ -48,4 +34,4 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
}
})