2024-08-15 23:58:07 +02:00
|
|
|
{
|
|
|
|
|
lib,
|
|
|
|
|
stdenv,
|
|
|
|
|
bun,
|
|
|
|
|
callPackage,
|
2024-08-24 18:37:18 +02:00
|
|
|
modulesSrc ? callPackage ./source.nix {},
|
2024-08-15 23:58:07 +02:00
|
|
|
nodePackages_latest,
|
|
|
|
|
makeBinaryWrapper,
|
|
|
|
|
}:
|
|
|
|
|
|
2024-08-24 18:37:18 +02:00
|
|
|
assert lib.assertMsg (
|
|
|
|
|
with builtins; hashFile "sha256" ../bun.lockb == hashFile "sha256" "${modulesSrc.src}/bun.lockb"
|
|
|
|
|
) "bun.lockb has changed. Please run 'nix run .#apps.x86_64-linux.update-modules'";
|
|
|
|
|
|
2024-08-15 23:58:07 +02:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
|
pname = "versiajs";
|
|
|
|
|
version = "0.7.0";
|
|
|
|
|
|
|
|
|
|
src = ../.;
|
|
|
|
|
|
2024-08-24 18:37:18 +02:00
|
|
|
versiajsModules = stdenv.mkDerivation (modulesAttrs: {
|
|
|
|
|
pname = "${finalAttrs.pname}-modules";
|
|
|
|
|
|
|
|
|
|
inherit (finalAttrs) version;
|
2024-08-15 23:58:07 +02:00
|
|
|
|
2024-08-24 18:37:18 +02:00
|
|
|
src = modulesSrc.src;
|
2024-08-15 23:58:07 +02:00
|
|
|
|
|
|
|
|
nativeBuildInputs = with nodePackages_latest; [ bun nodejs typescript ];
|
|
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
|
bun install --production --no-progress --ignore-scripts --frozen-lockfile
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
mkdir -p $out/node_modules
|
|
|
|
|
cp -r node_modules $out
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
dontFixup = true;
|
|
|
|
|
|
2024-08-24 18:37:18 +02:00
|
|
|
outputHash = modulesSrc.outputHash.${stdenv.system};
|
2024-08-15 23:58:07 +02:00
|
|
|
outputHashMode = "recursive";
|
2024-08-24 18:37:18 +02:00
|
|
|
});
|
2024-08-15 23:58:07 +02:00
|
|
|
|
|
|
|
|
nativeBuildInputs = [ bun ];
|
|
|
|
|
|
|
|
|
|
buildInputs = [ bun nodePackages_latest.nodejs makeBinaryWrapper ];
|
|
|
|
|
|
|
|
|
|
patches = [ ./fix-build-spinner.patch ];
|
|
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
|
runHook preConfigure
|
|
|
|
|
|
2024-08-24 18:37:18 +02:00
|
|
|
cp -r ${finalAttrs.versiajsModules}/node_modules .
|
2024-08-15 23:58:07 +02:00
|
|
|
|
|
|
|
|
runHook postConfigure
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
|
|
bun run build
|
|
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
|
|
cp -r dist/ $out
|
|
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
|
|
|
|
|
makeBinaryWrapper ${bun}/bin/bun $out/bin/versiajs \
|
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ bun ]} \
|
|
|
|
|
--set NODE_ENV "production" \
|
|
|
|
|
--add-flags "run --prefer-offline --no-install --cwd $out $out/index.js"
|
|
|
|
|
|
|
|
|
|
makeBinaryWrapper ${bun}/bin/bun $out/bin/versiajs-cli \
|
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ bun ]} \
|
|
|
|
|
--add-flags "run --prefer-offline --no-install --cwd $out $out/cli/index.js"
|
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
2024-08-24 18:37:18 +02:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
|
2024-08-15 23:58:07 +02:00
|
|
|
meta = {
|
|
|
|
|
description = "A new federated server written with TypeScript and Bun ";
|
2024-08-26 17:45:14 +02:00
|
|
|
homepage = "https://versia.pub";
|
2024-08-15 23:58:07 +02:00
|
|
|
license = with lib.licenses; [ agpl3Plus ];
|
|
|
|
|
maintainers = with lib.maintainers; [ snaki ];
|
2024-08-24 18:37:18 +02:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
2024-08-15 23:58:07 +02:00
|
|
|
};
|
|
|
|
|
})
|