mirror of
https://github.com/versia-pub/server.git
synced 2026-03-12 21:39:15 +01:00
fix: 💚 Fix the Nix build, remove dependency on PNPM
This commit is contained in:
parent
30bb801f9f
commit
eb096c5991
8 changed files with 71 additions and 6899 deletions
|
|
@ -2,14 +2,8 @@
|
|||
{versia-server, ...}:
|
||||
versia-server.overrideAttrs (oldAttrs: {
|
||||
pname = "${oldAttrs.pname}-worker";
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
bun run packages/worker/build.ts
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
entrypointPath = "packages/worker/index.js";
|
||||
buildType = "worker";
|
||||
|
||||
meta =
|
||||
oldAttrs.meta
|
||||
|
|
|
|||
|
|
@ -5,10 +5,8 @@
|
|||
nodejs,
|
||||
vips,
|
||||
makeWrapper,
|
||||
fetchBunDeps,
|
||||
bunConfigHook,
|
||||
bunInstallHook,
|
||||
bunBuildHook,
|
||||
stdenvNoCC,
|
||||
writableTmpDirAsHomeHook,
|
||||
...
|
||||
}: let
|
||||
packageJson = builtins.fromJSON (builtins.readFile ../package.json);
|
||||
|
|
@ -19,23 +17,70 @@ in
|
|||
|
||||
src = ../.;
|
||||
|
||||
bunOfflineCache = fetchBunDeps {
|
||||
bunLock = finalAttrs.src + "/bun.lock";
|
||||
hash = "sha256-8R+LzgqAiqRGCMDBw2R7QO6hbdNrtIwzSjR3A8xhfVw=";
|
||||
};
|
||||
node_modules = stdenvNoCC.mkDerivation {
|
||||
pname = "${finalAttrs.pname}-node_modules";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
bunBuildScript = "packages/api/build.ts";
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
nodejs
|
||||
writableTmpDirAsHomeHook
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
|
||||
|
||||
bun install \
|
||||
--force \
|
||||
--frozen-lockfile \
|
||||
--no-progress
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/node_modules
|
||||
cp -R ./node_modules $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# Required else we get errors that our fixed-output derivation references store paths
|
||||
dontFixup = true;
|
||||
|
||||
outputHash = "sha256-/RQv87hjLdH6+41yR7+bGp3j200DVhIrKWoI1MKIqJs=";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
nodejs
|
||||
makeWrapper
|
||||
bunConfigHook
|
||||
bunInstallHook
|
||||
bunBuildHook
|
||||
];
|
||||
|
||||
entrypointPath = "packages/api/index.js";
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
cp -R ${finalAttrs.node_modules}/node_modules .
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
bun run build ${finalAttrs.buildType}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
buildType = "api";
|
||||
|
||||
installPhase = let
|
||||
libPath = lib.makeLibraryPath [
|
||||
|
|
@ -53,7 +98,7 @@ in
|
|||
cp -r dist $out/${finalAttrs.pname}
|
||||
|
||||
makeWrapper ${lib.getExe bun} $out/bin/${finalAttrs.pname} \
|
||||
--add-flags "run $out/${finalAttrs.pname}/${finalAttrs.entrypointPath}" \
|
||||
--add-flags "run $out/${finalAttrs.pname}/${finalAttrs.buildType}.js" \
|
||||
--set NODE_PATH $out/${finalAttrs.pname}/node_modules \
|
||||
--set MSGPACKR_NATIVE_ACCELERATION_DISABLED true \
|
||||
--prefix PATH : ${binPath} \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue