Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
126
nix/package.nix
Normal file
126
nix/package.nix
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
{
|
||||
lib,
|
||||
buildGo126Module,
|
||||
fetchPnpmDeps,
|
||||
nodejs_24,
|
||||
pnpm,
|
||||
pnpmConfigHook,
|
||||
stdenvNoCC,
|
||||
}:
|
||||
let
|
||||
version = "dev";
|
||||
|
||||
frontendSource = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.unions [
|
||||
../package.json
|
||||
../pnpm-lock.yaml
|
||||
../pnpm-workspace.yaml
|
||||
../frontend/package.json
|
||||
../frontend/index.html
|
||||
../frontend/eslint.config.js
|
||||
../frontend/tsconfig.json
|
||||
../frontend/tsconfig.node.json
|
||||
../frontend/vite.config.ts
|
||||
../frontend/src
|
||||
];
|
||||
};
|
||||
|
||||
frontend = stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "vibe-proxy-frontend";
|
||||
inherit version;
|
||||
src = frontendSource;
|
||||
|
||||
pnpmDeps = fetchPnpmDeps {
|
||||
inherit (finalAttrs) pname version src;
|
||||
fetcherVersion = 4;
|
||||
hash = "sha256-vpiGYrLY5B+irYJf4lAs3SM9RrmEb9t+BJHBVXQGP+I=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs_24
|
||||
pnpm
|
||||
pnpmConfigHook
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
pnpm --dir frontend exec tsc
|
||||
pnpm --dir frontend exec vite build
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/share/vibe-proxy/frontend
|
||||
cp -r frontend/dist/. $out/share/vibe-proxy/frontend/
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Vibe Proxy management frontend";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
});
|
||||
|
||||
backendRoot = toString ../backend;
|
||||
backendSource = lib.cleanSourceWith {
|
||||
src = ../backend;
|
||||
filter =
|
||||
path: type:
|
||||
let
|
||||
relative = lib.removePrefix "${backendRoot}/" (toString path);
|
||||
in
|
||||
lib.cleanSourceFilter path type
|
||||
&& relative != "cli-proxy-api"
|
||||
&& relative != ".dev"
|
||||
&& !lib.hasPrefix ".dev/" relative
|
||||
&& !lib.hasPrefix "internal/managementasset/dist/" relative;
|
||||
};
|
||||
|
||||
buildBackend =
|
||||
{ embedFrontend }:
|
||||
buildGo126Module {
|
||||
pname = if embedFrontend then "vibe-proxy" else "vibe-proxy-backend";
|
||||
inherit version;
|
||||
src = backendSource;
|
||||
vendorHash = "sha256-CrDp7MOr+AwJUhTovklXx3F1yaktQlvD7VYhYSY6VvY=";
|
||||
subPackages = [ "cmd/server" ];
|
||||
tags = lib.optional embedFrontend "frontend";
|
||||
env.CGO_ENABLED = "1";
|
||||
|
||||
preBuild = lib.optionalString embedFrontend ''
|
||||
rm -rf internal/managementasset/dist
|
||||
mkdir -p internal/managementasset/dist
|
||||
cp -r ${frontend}/share/vibe-proxy/frontend/. internal/managementasset/dist/
|
||||
'';
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X main.Version=${version}"
|
||||
"-X main.Commit=nix"
|
||||
"-X main.BuildDate=reproducible"
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
mv $out/bin/server $out/bin/vibe-proxy
|
||||
mkdir -p $out/share/vibe-proxy
|
||||
cp config.example.yaml $out/share/vibe-proxy/config.example.yaml
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "OpenAI-compatible proxy server${lib.optionalString embedFrontend " with an embedded management UI"}";
|
||||
homepage = "https://github.com/router-for-me/CLIProxyAPI";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "vibe-proxy";
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit frontend;
|
||||
backend = buildBackend { embedFrontend = false; };
|
||||
combined = buildBackend { embedFrontend = true; };
|
||||
}
|
||||
Loading…
Reference in a new issue