mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat: Add nix package
This commit is contained in:
parent
76e3acbe53
commit
3ce2443484
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -117,6 +117,10 @@ out
|
||||||
.nuxt
|
.nuxt
|
||||||
dist
|
dist
|
||||||
|
|
||||||
|
# Nix build output
|
||||||
|
|
||||||
|
result
|
||||||
|
|
||||||
# Gatsby files
|
# Gatsby files
|
||||||
|
|
||||||
.cache/
|
.cache/
|
||||||
|
|
@ -182,4 +186,4 @@ glitch-dev
|
||||||
*.pem
|
*.pem
|
||||||
oclif.manifest.json
|
oclif.manifest.json
|
||||||
.direnv/
|
.direnv/
|
||||||
tsconfig.tsbuildinfo
|
tsconfig.tsbuildinfo
|
||||||
|
|
|
||||||
33
nix/fix-build-spinner.patch
Normal file
33
nix/fix-build-spinner.patch
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
diff --git a/build.ts b/build.ts
|
||||||
|
index 3b3ebe9..9531121 100644
|
||||||
|
--- a/build.ts
|
||||||
|
+++ b/build.ts
|
||||||
|
@@ -1,10 +1,10 @@
|
||||||
|
import { $ } from "bun";
|
||||||
|
-import ora from "ora";
|
||||||
|
+// import ora from "ora";
|
||||||
|
import { routes } from "~/routes";
|
||||||
|
|
||||||
|
-const buildSpinner = ora("Building").start();
|
||||||
|
+// const buildSpinner = ora("Building").start();
|
||||||
|
|
||||||
|
-await $`rm -rf dist && mkdir dist`;
|
||||||
|
+// await $`rm -rf dist && mkdir dist`;
|
||||||
|
|
||||||
|
await Bun.build({
|
||||||
|
entrypoints: [
|
||||||
|
@@ -25,7 +25,7 @@ await Bun.build({
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
-buildSpinner.text = "Transforming";
|
||||||
|
+// buildSpinner.text = "Transforming";
|
||||||
|
|
||||||
|
// Copy Drizzle migrations to dist
|
||||||
|
await $`cp -r drizzle dist/drizzle`;
|
||||||
|
@@ -49,4 +49,4 @@ await $`cp package.json dist/package.json`;
|
||||||
|
// Copy cli/theme.json
|
||||||
|
await $`cp cli/theme.json dist/cli/theme.json`;
|
||||||
|
|
||||||
|
-buildSpinner.stop();
|
||||||
|
+// buildSpinner.stop();
|
||||||
6
nix/nodeHashes.nix
Normal file
6
nix/nodeHashes.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{ lib }: {
|
||||||
|
x86_64-linux = "sha256-T/U9altP5HFzmULtsuvHQIXQXDCmQEAau8KFN8J5i/8=";
|
||||||
|
x86_64-darwin = lib.fakeHash;
|
||||||
|
aarch64-linux = "sha256-6ZzrYI2G+7q9Efgu5iKhZB3bT2C7T5fk4I/t5glpQYA=";
|
||||||
|
aarch64-darwin = lib.fakeHash;
|
||||||
|
}
|
||||||
90
nix/package.nix
Normal file
90
nix/package.nix
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
fetchFromGitHub,
|
||||||
|
bun,
|
||||||
|
callPackage,
|
||||||
|
nodeHashes ? callPackage ./nodeHashes.nix { inherit lib; },
|
||||||
|
nodePackages_latest,
|
||||||
|
makeBinaryWrapper,
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
pname = "versiajs";
|
||||||
|
version = "0.7.0";
|
||||||
|
|
||||||
|
src = ../.;
|
||||||
|
|
||||||
|
node_modules = stdenv.mkDerivation {
|
||||||
|
pname = "${finalAttrs.pname}-node_modules";
|
||||||
|
|
||||||
|
inherit (finalAttrs) version src;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
outputHash = nodeHashes.${stdenv.system};
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ bun ];
|
||||||
|
|
||||||
|
buildInputs = [ bun nodePackages_latest.nodejs makeBinaryWrapper ];
|
||||||
|
|
||||||
|
patches = [ ./fix-build-spinner.patch ];
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
runHook preConfigure
|
||||||
|
|
||||||
|
cp -r ${finalAttrs.node_modules}/node_modules .
|
||||||
|
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "A new federated server written with TypeScript and Bun ";
|
||||||
|
homepage = "https://lysand.org";
|
||||||
|
license = with lib.licenses; [ agpl3Plus ];
|
||||||
|
maintainers = with lib.maintainers; [ snaki ];
|
||||||
|
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
};
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue