2021-07-01 00:10:12 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2023-05-26 02:16:41 +00:00
|
|
|
, buildGoModule
|
|
|
|
, buildNpmPackage
|
|
|
|
, makeWrapper
|
|
|
|
, go-swag
|
2023-05-16 15:34:14 +00:00
|
|
|
, nixosTests
|
2023-08-27 09:42:31 +00:00
|
|
|
, testers
|
|
|
|
, pufferpanel
|
2021-07-01 00:10:12 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "pufferpanel";
|
2023-08-27 09:42:31 +00:00
|
|
|
version = "2.6.9";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "PufferPanel";
|
|
|
|
repo = "PufferPanel";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-+ZZUoqCiSbrkaeYrm9X8SuX0INsGFegQNwa3WjBvgHQ=";
|
2023-05-26 02:16:41 +00:00
|
|
|
};
|
2023-03-11 19:30:25 +00:00
|
|
|
|
2023-08-27 09:42:31 +00:00
|
|
|
patches = [
|
|
|
|
# Bump sha1cd package, otherwise i686-linux fails to build.
|
|
|
|
./bump-sha1cd.patch
|
|
|
|
|
|
|
|
# Seems to be an anti-feature. Startup is the only place where user/group is
|
|
|
|
# hardcoded and checked.
|
|
|
|
#
|
|
|
|
# There is no technical reason PufferPanel cannot run as a different user,
|
|
|
|
# especially for simple commands like `pufferpanel version`.
|
|
|
|
./disable-group-checks.patch
|
|
|
|
|
|
|
|
# Some tests do not have network requests stubbed :(
|
|
|
|
./skip-network-tests.patch
|
|
|
|
];
|
|
|
|
|
2023-03-11 19:30:25 +00:00
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X=github.com/pufferpanel/pufferpanel/v2.Hash=none"
|
|
|
|
"-X=github.com/pufferpanel/pufferpanel/v2.Version=${version}-nixpkgs"
|
|
|
|
];
|
2021-07-01 00:10:12 +00:00
|
|
|
|
2023-05-26 02:16:41 +00:00
|
|
|
frontend = buildNpmPackage {
|
|
|
|
pname = "pufferpanel-frontend";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = "${src}/client";
|
2021-07-01 00:10:12 +00:00
|
|
|
|
2023-07-08 07:48:46 +00:00
|
|
|
npmDepsHash = "sha256-oWFXtV/dxzHv3sfIi01l1lHE5tcJgpVq87XgS6Iy62g=";
|
2023-05-26 02:16:41 +00:00
|
|
|
|
|
|
|
NODE_OPTIONS = "--openssl-legacy-provider";
|
|
|
|
npmBuildFlags = [ "--" "--dest=${placeholder "out"}" ];
|
|
|
|
dontNpmInstall = true;
|
2023-03-11 19:30:25 +00:00
|
|
|
};
|
2021-07-01 00:10:12 +00:00
|
|
|
|
2023-05-26 02:16:41 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper go-swag ];
|
2021-07-01 00:10:12 +00:00
|
|
|
|
2023-08-27 09:42:31 +00:00
|
|
|
vendorHash = "sha256-402ND99FpU+zNV1e5Th1+aZKok49cIEdpPPLLfNyL3E=";
|
2023-03-11 19:30:25 +00:00
|
|
|
proxyVendor = true;
|
2021-07-01 00:10:12 +00:00
|
|
|
|
2023-05-26 02:16:41 +00:00
|
|
|
# Generate code for Swagger documentation endpoints (see web/swagger/docs.go).
|
|
|
|
# Note that GOROOT embedded in go-swag is empty by default since it is built
|
|
|
|
# with -trimpath (see https://go.dev/cl/399214). It looks like go-swag skips
|
|
|
|
# file paths that start with $GOROOT, thus all files when it is empty.
|
|
|
|
preBuild = ''
|
|
|
|
GOROOT=''${GOROOT-$(go env GOROOT)} swag init --output web/swagger --generalInfo web/loader.go
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2021-07-01 00:10:12 +00:00
|
|
|
|
2023-05-26 02:16:41 +00:00
|
|
|
# Set up directory structure similar to the official PufferPanel releases.
|
|
|
|
mkdir -p $out/share/pufferpanel
|
|
|
|
cp "$GOPATH"/bin/cmd $out/share/pufferpanel/pufferpanel
|
|
|
|
cp -r $frontend $out/share/pufferpanel/www
|
|
|
|
cp -r $src/assets/email $out/share/pufferpanel/email
|
|
|
|
cp web/swagger/swagger.{json,yaml} $out/share/pufferpanel
|
2023-03-11 19:30:25 +00:00
|
|
|
|
|
|
|
# Wrap the binary with the path to the external files, but allow setting
|
|
|
|
# custom paths if needed.
|
2023-05-26 02:16:41 +00:00
|
|
|
makeWrapper $out/share/pufferpanel/pufferpanel $out/bin/pufferpanel \
|
2023-03-11 19:30:25 +00:00
|
|
|
--set-default GIN_MODE release \
|
2023-05-26 02:16:41 +00:00
|
|
|
--set-default PUFFER_PANEL_EMAIL_TEMPLATES $out/share/pufferpanel/email/emails.json \
|
2023-06-10 13:59:27 +00:00
|
|
|
--set-default PUFFER_PANEL_WEB_FILES $out/share/pufferpanel/www
|
2023-05-26 02:16:41 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2021-07-01 00:10:12 +00:00
|
|
|
'';
|
|
|
|
|
2023-05-16 15:34:14 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) pufferpanel;
|
2023-08-27 09:42:31 +00:00
|
|
|
version = testers.testVersion {
|
|
|
|
package = pufferpanel;
|
|
|
|
command = "${pname} version";
|
|
|
|
};
|
2023-05-16 15:34:14 +00:00
|
|
|
};
|
|
|
|
|
2021-07-01 00:10:12 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A free, open source game management panel";
|
|
|
|
homepage = "https://www.pufferpanel.com/";
|
|
|
|
license = with licenses; [ asl20 ];
|
2023-04-09 06:29:13 +00:00
|
|
|
maintainers = with maintainers; [ ckie tie ];
|
2023-07-31 19:21:43 +00:00
|
|
|
mainProgram = "pufferpanel";
|
2021-07-01 00:10:12 +00:00
|
|
|
};
|
|
|
|
}
|