diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-08-08 16:04:42 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-08-13 06:35:37 +0000 |
commit | 12aaa58dac35800b5b7d77f81cf2a87c21ee55da (patch) | |
tree | be0add9e5c22a85d20b5d78206aa74f956eb2a1b /nixpkgs/pkgs/servers/pufferpanel | |
parent | 45892a5591202f75a1c2f1ca7c62a92c7566e3c5 (diff) | |
parent | 5a8e9243812ba528000995b294292d3b5e120947 (diff) | |
download | nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.gz nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.bz2 nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.lz nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.xz nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.tar.zst nixlib-12aaa58dac35800b5b7d77f81cf2a87c21ee55da.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/pkgs/applications/window-managers/sway/default.nix nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix nixpkgs/pkgs/development/libraries/mesa/default.nix nixpkgs/pkgs/servers/dict/dictd-db.nix Link: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/issues/391
Diffstat (limited to 'nixpkgs/pkgs/servers/pufferpanel')
-rw-r--r-- | nixpkgs/pkgs/servers/pufferpanel/default.nix | 126 |
1 files changed, 62 insertions, 64 deletions
diff --git a/nixpkgs/pkgs/servers/pufferpanel/default.nix b/nixpkgs/pkgs/servers/pufferpanel/default.nix index f8c61ea17691..d3420f90db54 100644 --- a/nixpkgs/pkgs/servers/pufferpanel/default.nix +++ b/nixpkgs/pkgs/servers/pufferpanel/default.nix @@ -1,43 +1,40 @@ { lib -, buildGoModule , fetchFromGitHub -, makeWrapper -, fetchzip , fetchpatch -, pathDeps ? [ ] +, applyPatches +, buildGoModule +, buildNpmPackage +, makeWrapper +, go-swag , nixosTests }: buildGoModule rec { pname = "pufferpanel"; - version = "2.6.6"; - - patches = [ - # Bump go-sqlite3 version to avoid a GNU C compiler error. - (fetchpatch { - url = "https://github.com/PufferPanel/PufferPanel/commit/dd7fc80c33c7618c98311af09c78c25b77658aef.patch"; - hash = "sha256-ygMrhJoba8swoRBBii7BEiLihqOebLUtSH7os7W3s+k="; - }) - - # Fix errors in tests. - (fetchpatch { - url = "https://github.com/PufferPanel/PufferPanel/commit/ad6ab4b4368e1111292fadfb3d9f058fa399fa21.patch"; - hash = "sha256-BzGfcWhzRrCHKkAhWf0uvXiiiutWqthn/ed7bN2hR8U="; - }) - - # 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 - ]; + version = "2.6.7"; + + src = applyPatches { + src = fetchFromGitHub { + owner = "PufferPanel"; + repo = "PufferPanel"; + rev = "v${version}"; + hash = "sha256-ay9NNcK+6QFobe/rwtZF8USl0vMbDZBg5z57fjA5VLw="; + }; + 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 + ]; + }; ldflags = [ "-s" @@ -46,50 +43,50 @@ buildGoModule rec { "-X=github.com/pufferpanel/pufferpanel/v2.Version=${version}-nixpkgs" ]; - src = fetchFromGitHub { - owner = "pufferpanel"; - repo = pname; - rev = "v${version}"; - hash = "sha256-0Vyi47Rkpe3oODHfsl/7tCerENpiEa3EWBHhfTO/uu4="; - }; + frontend = buildNpmPackage { + pname = "pufferpanel-frontend"; + inherit version; - # PufferPanel is split into two parts: the backend daemon and the - # frontend. - # Getting the frontend to build in the Nix environment fails even - # with all the proper node_modules populated. To work around this, - # we just download the built frontend and package that. - frontend = fetchzip { - url = "https://github.com/PufferPanel/PufferPanel/releases/download/v${version}/pufferpanel_${version}_linux_arm64.zip"; - hash = "sha256-z7HWhiEBma37OMGEkTGaEbnF++Nat8wAZE2UeOoaO/U="; - stripRoot = false; - postFetch = '' - mv $out $TMPDIR/subdir - mv $TMPDIR/subdir/www $out - ''; + src = "${src}/client"; + + npmDepsHash = "sha256-oWFXtV/dxzHv3sfIi01l1lHE5tcJgpVq87XgS6Iy62g="; + + NODE_OPTIONS = "--openssl-legacy-provider"; + npmBuildFlags = [ "--" "--dest=${placeholder "out"}" ]; + dontNpmInstall = true; }; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ makeWrapper go-swag ]; vendorHash = "sha256-Esfk7SvqiWeiobXSI+4wYVEH9yVkB+rO7bxUQ5TzvG4="; proxyVendor = true; - postFixup = '' - mkdir -p $out/share/pufferpanel - cp -r ${src}/assets/email $out/share/pufferpanel/templates - cp -r ${frontend} $out/share/pufferpanel/www + # 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 + ''; - # Rename cmd to pufferpanel and remove other binaries. - mv $out/bin $TMPDIR/bin - mkdir $out/bin - mv $TMPDIR/bin/cmd $out/bin/pufferpanel + installPhase = '' + runHook preInstall + + # 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 # Wrap the binary with the path to the external files, but allow setting # custom paths if needed. - wrapProgram $out/bin/pufferpanel \ + makeWrapper $out/share/pufferpanel/pufferpanel $out/bin/pufferpanel \ --set-default GIN_MODE release \ - --set-default PUFFER_PANEL_EMAIL_TEMPLATES $out/share/pufferpanel/templates/emails.json \ - --set-default PUFFER_PANEL_WEB_FILES $out/share/pufferpanel/www \ - --prefix PATH : ${lib.escapeShellArg (lib.makeBinPath pathDeps)} + --set-default PUFFER_PANEL_EMAIL_TEMPLATES $out/share/pufferpanel/email/emails.json \ + --set-default PUFFER_PANEL_WEB_FILES $out/share/pufferpanel/www + + runHook postInstall ''; passthru.tests = { @@ -101,5 +98,6 @@ buildGoModule rec { homepage = "https://www.pufferpanel.com/"; license = with licenses; [ asl20 ]; maintainers = with maintainers; [ ckie tie ]; + mainProgram = "pufferpanel"; }; } |