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

authored by Doron Behar and committed by GitHub 7e16b797 eca4eaf5

+36 -50
+23 -23
pkgs/by-name/go/gotify-server/package.nix
··· 8 8 nix-update-script, 9 9 }: 10 10 11 - buildGoModule rec { 11 + buildGoModule (finalAttrs: { 12 12 pname = "gotify-server"; 13 13 version = "2.6.3"; 14 14 15 15 src = fetchFromGitHub { 16 16 owner = "gotify"; 17 17 repo = "server"; 18 - rev = "v${version}"; 18 + tag = "v${finalAttrs.version}"; 19 19 hash = "sha256-9vIReA29dWf3QwUYEW8JhzF9o74JZqG4zGobgI+gIWE="; 20 20 }; 21 21 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 - 28 22 vendorHash = "sha256-rs6EfnJT6Jgif2TR5u5Tp5/Ozn+4uhSapksyKFnQiCo="; 29 23 24 + # No test 30 25 doCheck = false; 31 26 32 27 buildInputs = [ 33 28 sqlite 34 29 ]; 35 30 36 - ui = callPackage ./ui.nix { }; 31 + ui = callPackage ./ui.nix { inherit (finalAttrs) src version; }; 37 32 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 43 36 ''; 44 37 45 38 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 + }; 50 45 tests = { 51 46 nixos = nixosTests.gotify-server; 52 47 }; ··· 56 51 # produce binaries which panic when executed and are not interesting at all 57 52 subPackages = [ "." ]; 58 53 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 59 56 ldflags = [ 60 - "-X main.Version=${version}" 57 + "-s" 58 + "-X main.Version=${finalAttrs.version}" 61 59 "-X main.Mode=prod" 60 + "-X main.Commit=refs/tags/v${finalAttrs.version}" 61 + "-X main.BuildDate=unknown" 62 62 ]; 63 63 64 - meta = with lib; { 64 + meta = { 65 65 description = "Simple server for sending and receiving messages in real-time per WebSocket"; 66 66 homepage = "https://gotify.net"; 67 - license = licenses.mit; 68 - maintainers = with maintainers; [ doronbehar ]; 67 + license = lib.licenses.mit; 68 + maintainers = with lib.maintainers; [ doronbehar ]; 69 69 mainProgram = "server"; 70 70 }; 71 - } 71 + })
+13 -27
pkgs/by-name/go/gotify-server/ui.nix
··· 1 1 { 2 + src, 3 + version, 2 4 stdenv, 3 - yarn, 4 - fixup-yarn-lock, 5 + yarnConfigHook, 6 + yarnBuildHook, 5 7 nodejs-slim, 6 8 fetchYarnDeps, 7 - gotify-server, 8 9 }: 9 10 10 - stdenv.mkDerivation rec { 11 + stdenv.mkDerivation (finalAttrs: { 11 12 pname = "gotify-ui"; 12 - inherit (gotify-server) version; 13 + inherit version; 13 14 14 - src = gotify-server.src + "/ui"; 15 + src = src + "/ui"; 15 16 16 - offlineCache = fetchYarnDeps { 17 - yarnLock = "${src}/yarn.lock"; 17 + yarnOfflineCache = fetchYarnDeps { 18 + yarnLock = "${finalAttrs.src}/yarn.lock"; 18 19 hash = "sha256-ejHzo6NHCMlNiYePWvfMY9Blb58pj3UQ5PFI0V84flI="; 19 20 }; 20 21 21 22 nativeBuildInputs = [ 22 - yarn 23 - fixup-yarn-lock 23 + yarnConfigHook 24 + yarnBuildHook 24 25 nodejs-slim 25 26 ]; 26 27 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"; 43 29 44 30 installPhase = '' 45 31 runHook preInstall ··· 48 34 49 35 runHook postInstall 50 36 ''; 51 - } 37 + })