{ungoogled-,}chromium,chromedriver: 130.0.6723.58 -> 130.0.6723.69 (#351519)
[NixPkgs.git] / pkgs / servers / pufferpanel / default.nix
blobe70106200b13083ffd45ae7c19a3df5d545fb05f
1 { lib
2 , fetchFromGitHub
3 , buildGoModule
4 , buildNpmPackage
5 , makeWrapper
6 , go-swag
7 , nixosTests
8 , testers
9 , pufferpanel
12 buildGoModule rec {
13   pname = "pufferpanel";
14   version = "2.6.9";
16   src = fetchFromGitHub {
17     owner = "PufferPanel";
18     repo = "PufferPanel";
19     rev = "v${version}";
20     hash = "sha256-+ZZUoqCiSbrkaeYrm9X8SuX0INsGFegQNwa3WjBvgHQ=";
21   };
23   patches = [
24     # Bump sha1cd package, otherwise i686-linux fails to build.
25     # Also bump github.com/swaggo/swag for PR 257790.
26     ./deps.patch
28     # Seems to be an anti-feature. Startup is the only place where user/group is
29     # hardcoded and checked.
30     #
31     # There is no technical reason PufferPanel cannot run as a different user,
32     # especially for simple commands like `pufferpanel version`.
33     ./disable-group-checks.patch
35     # Some tests do not have network requests stubbed :(
36     ./skip-network-tests.patch
37   ];
39   ldflags = [
40     "-s"
41     "-w"
42     "-X=github.com/pufferpanel/pufferpanel/v2.Hash=none"
43     "-X=github.com/pufferpanel/pufferpanel/v2.Version=${version}-nixpkgs"
44   ];
46   frontend = buildNpmPackage {
47     pname = "pufferpanel-frontend";
48     inherit version;
50     src = "${src}/client";
52     npmDepsHash = "sha256-oWFXtV/dxzHv3sfIi01l1lHE5tcJgpVq87XgS6Iy62g=";
54     NODE_OPTIONS = "--openssl-legacy-provider";
55     npmBuildFlags = [ "--" "--dest=${placeholder "out"}" ];
56     dontNpmInstall = true;
57   };
59   nativeBuildInputs = [ makeWrapper go-swag ];
61   vendorHash = "sha256-1U7l7YW1fu5M0/pPHTLamLsTQdEltesRODUn21SuP8w=";
62   proxyVendor = true;
64   # Generate code for Swagger documentation endpoints (see web/swagger/docs.go).
65   # Note that GOROOT embedded in go-swag is empty by default since it is built
66   # with -trimpath (see https://go.dev/cl/399214). It looks like go-swag skips
67   # file paths that start with $GOROOT, thus all files when it is empty.
68   preBuild = ''
69     GOROOT=''${GOROOT-$(go env GOROOT)} swag init --output web/swagger --generalInfo web/loader.go
70   '';
72   installPhase = ''
73     runHook preInstall
75     # Set up directory structure similar to the official PufferPanel releases.
76     mkdir -p $out/share/pufferpanel
77     cp "$GOPATH"/bin/cmd $out/share/pufferpanel/pufferpanel
78     cp -r $frontend $out/share/pufferpanel/www
79     cp -r $src/assets/email $out/share/pufferpanel/email
80     cp web/swagger/swagger.{json,yaml} $out/share/pufferpanel
82     # Wrap the binary with the path to the external files, but allow setting
83     # custom paths if needed.
84     makeWrapper $out/share/pufferpanel/pufferpanel $out/bin/pufferpanel \
85       --set-default GIN_MODE release \
86       --set-default PUFFER_PANEL_EMAIL_TEMPLATES $out/share/pufferpanel/email/emails.json \
87       --set-default PUFFER_PANEL_WEB_FILES $out/share/pufferpanel/www
89     runHook postInstall
90   '';
92   passthru.tests = {
93     inherit (nixosTests) pufferpanel;
94     version = testers.testVersion {
95       package = pufferpanel;
96       command = "${pname} version";
97     };
98   };
100   meta = with lib; {
101     description = "Free, open source game management panel";
102     homepage = "https://www.pufferpanel.com/";
103     license = with licenses; [ asl20 ];
104     maintainers = with maintainers; [ tie ];
105     mainProgram = "pufferpanel";
106   };