From 5c6d52cb60dd873621b07f6cb126e79d85f5df18 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Mon, 30 Jun 2025 00:57:22 +0800 Subject: [PATCH 1/3] gotify-server: remove Go reference https://github.com/gotify/server/pull/581 --- pkgs/by-name/go/gotify-server/package.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkgs/by-name/go/gotify-server/package.nix b/pkgs/by-name/go/gotify-server/package.nix index 1ddcc27bd420..9ffe22d027f6 100644 --- a/pkgs/by-name/go/gotify-server/package.nix +++ b/pkgs/by-name/go/gotify-server/package.nix @@ -19,12 +19,6 @@ buildGoModule rec { 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="; doCheck = false; From ccfe830713908b04d7136dcc400a2b85818cddd6 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Mon, 30 Jun 2025 01:07:52 +0800 Subject: [PATCH 2/3] gotify-server: modernize - Use finalAttrs. - Add missing ldflags https://github.com/gotify/server/blob/v2.6.3/.github/workflows/build.yml#L33. --- pkgs/by-name/go/gotify-server/package.nix | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/go/gotify-server/package.nix b/pkgs/by-name/go/gotify-server/package.nix index 9ffe22d027f6..70d5cea80d41 100644 --- a/pkgs/by-name/go/gotify-server/package.nix +++ b/pkgs/by-name/go/gotify-server/package.nix @@ -8,19 +8,20 @@ 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="; }; vendorHash = "sha256-rs6EfnJT6Jgif2TR5u5Tp5/Ozn+4uhSapksyKFnQiCo="; + # No test doCheck = false; buildInputs = [ @@ -39,7 +40,7 @@ buildGoModule rec { passthru = { # For nix-update to detect the location of this attribute from this # derivation. - inherit (ui) offlineCache; + inherit (finalAttrs.ui) offlineCache; updateScript = nix-update-script { }; tests = { nixos = nixosTests.gotify-server; @@ -50,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"; }; -} +}) From 895138d1b7131e15b5103587341d7c16ba70f5c6 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Mon, 30 Jun 2025 01:19:44 +0800 Subject: [PATCH 3/3] gotify-server.ui: modernize - Use finalAttrs. - Use yarnConfigHook and yarnBuildHook. - nix-update specify ui subpackage. --- pkgs/by-name/go/gotify-server/package.nix | 20 ++++++------ pkgs/by-name/go/gotify-server/ui.nix | 40 ++++++++--------------- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/pkgs/by-name/go/gotify-server/package.nix b/pkgs/by-name/go/gotify-server/package.nix index 70d5cea80d41..7d972e514783 100644 --- a/pkgs/by-name/go/gotify-server/package.nix +++ b/pkgs/by-name/go/gotify-server/package.nix @@ -28,20 +28,20 @@ buildGoModule (finalAttrs: { 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 (finalAttrs.ui) offlineCache; - updateScript = nix-update-script { }; + updateScript = nix-update-script { + extraArgs = [ + "--subpackage" + "ui" + ]; + }; tests = { nixos = nixosTests.gotify-server; }; diff --git a/pkgs/by-name/go/gotify-server/ui.nix b/pkgs/by-name/go/gotify-server/ui.nix index 104b5670b994..432aeedafd60 100644 --- a/pkgs/by-name/go/gotify-server/ui.nix +++ b/pkgs/by-name/go/gotify-server/ui.nix @@ -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 ''; -} +})