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