Skip to content

Commit 895138d

Browse files
committed
gotify-server.ui: modernize
- Use finalAttrs. - Use yarnConfigHook and yarnBuildHook. - nix-update specify ui subpackage.
1 parent ccfe830 commit 895138d

File tree

2 files changed

+23
-37
lines changed

2 files changed

+23
-37
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ buildGoModule (finalAttrs: {
2828
sqlite
2929
];
3030

31-
ui = callPackage ./ui.nix { };
31+
ui = callPackage ./ui.nix { inherit (finalAttrs) src version; };
3232

33-
preBuild = ''
34-
if [ -n "$ui" ] # to make the preBuild a no-op inside the goModules fixed-output derivation, where it would fail
35-
then
36-
cp -r $ui ui/build
37-
fi
33+
# Use preConfigure instead of preBuild to keep goModules independent from ui
34+
preConfigure = ''
35+
cp -r ${finalAttrs.ui} ui/build
3836
'';
3937

4038
passthru = {
41-
# For nix-update to detect the location of this attribute from this
42-
# derivation.
43-
inherit (finalAttrs.ui) offlineCache;
44-
updateScript = nix-update-script { };
39+
updateScript = nix-update-script {
40+
extraArgs = [
41+
"--subpackage"
42+
"ui"
43+
];
44+
};
4545
tests = {
4646
nixos = nixosTests.gotify-server;
4747
};
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)