mirror of
https://github.com/Melorise/nPanel.git
synced 2026-11-07 14:49:35 +00:00
84 lines
1.8 KiB
Nix
84 lines
1.8 KiB
Nix
{ lib
|
|
, buildGoModule
|
|
, buildNpmPackage
|
|
, src
|
|
}:
|
|
|
|
let
|
|
version = "0.1.0-pre";
|
|
|
|
frontend = buildNpmPackage {
|
|
pname = "npanel-frontend";
|
|
inherit version src;
|
|
sourceRoot = "source/frontend";
|
|
|
|
npmDepsHash = "sha256-a2mwK+B7C59ANeRZFonyOY6m93mo0F1nv5M9+m9zjwY=";
|
|
npmBuildScript = "build:pro";
|
|
|
|
preBuild = ''
|
|
export NPANEL_FRONTEND_OUTDIR="$TMPDIR/npanel-web"
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
cp -r "$TMPDIR/npanel-web/." "$out"
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
mkBackend = {
|
|
name,
|
|
module,
|
|
main,
|
|
vendorHash,
|
|
}:
|
|
buildGoModule {
|
|
pname = name;
|
|
inherit version src;
|
|
sourceRoot = "source/${module}";
|
|
|
|
inherit vendorHash;
|
|
|
|
preBuild = lib.optionalString (module == "core") ''
|
|
rm -rf cmd/server/web/assets
|
|
mkdir -p cmd/server/web/assets
|
|
cp -r ${frontend}/assets/. cmd/server/web/assets/
|
|
cp ${frontend}/index.html cmd/server/web/index.html
|
|
cp ${frontend}/favicon.png cmd/server/web/favicon.png
|
|
'';
|
|
|
|
env.CGO_ENABLED = "0";
|
|
ldflags = [ "-s" "-w" ];
|
|
subPackages = [ main ];
|
|
|
|
postInstall = ''
|
|
mv "$out/bin/server" "$out/bin/${name}"
|
|
'';
|
|
|
|
meta = {
|
|
description = "nPanel ${name} service binary";
|
|
license = lib.licenses.gpl3Only;
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
};
|
|
|
|
core = mkBackend {
|
|
name = "npanel-core";
|
|
module = "core";
|
|
main = "cmd/server";
|
|
vendorHash = "sha256-K3CQww2ZlrgfIcpnRG8ev7z01t4DSRbFrA3xow8UTus=";
|
|
};
|
|
|
|
agent = mkBackend {
|
|
name = "npanel-agent";
|
|
module = "agent";
|
|
main = "cmd/server";
|
|
vendorHash = "sha256-5n0Jn3/SRHsKxQlYs1x43cT8rMNcXZlyJ8VHJMzXr3U=";
|
|
};
|
|
in
|
|
core // {
|
|
passthru = {
|
|
inherit agent frontend;
|
|
};
|
|
}
|