Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions pkgs/by-name/be/beszel/package.nix
Copy link
Contributor

@arunoruto arunoruto Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also regardin the nix-update-script, maybe an extraArgs argument should be passed down, so the webui also gets updated with the script (could be the cause for now auto-updates being triggered).
Something like this should work:

  passthru.updateScript = nix-update-script {
    extraArgs = [
      "--subpackage"
      "webui"
    ];
  };

If you want, you can put in this commit too, or I can make a separate PR after this gets merged (with 0.12.10 maybe?) since the folder structure changed...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I'm really new to writing nix modules so I don't think I understand what whis does, or your comment about rec and finalAttrs :P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would enable it to auto-update in the future and we don't have to fetch the correct hash values. Regarding the other comment, maybe look at this version of the nix file:

{
  buildGoModule,
  lib,
  fetchFromGitHub,
  nix-update-script,
  buildNpmPackage,
}:
buildGoModule (finalAttrs: {
  pname = "beszel";
  version = "0.12.10";

  src = fetchFromGitHub {
    owner = "henrygd";
    repo = "beszel";
    tag = "v${finalAttrs.version}";
    hash = "sha256-6hqRlttuDU5mAqgClc5I+lSx+XHpNPuOLirbVEA08/g=";
  };

  webui = buildNpmPackage {
    inherit (finalAttrs)
      pname
      version
      src
      meta
      ;

    npmFlags = [ "--legacy-peer-deps" ];

    buildPhase = ''
      runHook preBuild

      npx lingui extract --overwrite
      npx lingui compile
      node --max_old_space_size=1024000 ./node_modules/vite/bin/vite.js build

      runHook postBuild
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p $out
      cp -r dist/* $out

      runHook postInstall
    '';

    sourceRoot = "${finalAttrs.src.name}/internal/site";

    npmDepsHash = "sha256-8Y/Klpy2VIeg/o6n+EeYMvh0Y3GrNgIo7kRxYye3Rr4=";
  };

  # sourceRoot = "${src.name}";

  vendorHash = "sha256-8Y/Klpy2VIeg/o6n+EeYMvh0Y3GrNgIo7kRxYye3Rr4=";

  postPatch = ''substituteInPlace go.mod --replace "go 1.25.1" "go 1.25.0"'';

  preBuild = ''
    mkdir -p site/dist
    cp -r ${finalAttrs.webui}/* site/dist
  '';

  postInstall = ''
    mv $out/bin/agent $out/bin/beszel-agent
    mv $out/bin/hub $out/bin/beszel-hub
  '';

  passthru.updateScript = nix-update-script {
    extraArgs = [
      "--subpackage"
      "webui"
    ];
  };

  meta = {
    homepage = "https://github.com/henrygd/beszel";
    changelog = "https://github.com/henrygd/beszel/releases/tag/v${finalAttrs.version}";
    description = "Lightweight server monitoring hub with historical data, docker stats, and alerts";
    maintainers = with lib.maintainers; [ bot-wxt1221 ];
    license = lib.licenses.mit;
  };
})

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
nix-update-script,
buildNpmPackage,
}:
let
githubTag = "0.12.9";
sourceHash = "sha256-uyNY8vvagIINEVFKzoGB4oxvOIYwIg80yso8UDc1e/w=";
npmHash = "sha256-2zpJgkDXZoMWI6SkcfrhzozAITUR9ZUVtMbRtYKM13w=";
goHash = "sha256-8Sr7MYQnIfNx9hvfjCTYKQOUZIBxpGPbsR75jEB0mbk=";
in
buildGoModule rec {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rec should be slowly replaced with the finalAttrs syntax, which will make the let in block depricated.
I am also not sure if the update-script will work if the hashes are somewhere else in the nix file.

pname = "beszel";
version = "0.12.3";
version = githubTag;

src = fetchFromGitHub {
owner = "henrygd";
repo = "beszel";
tag = "v${version}";
hash = "sha256-rthaufUL0JX3sE2hdrcJ8J73DLK4/2wMR+uOs8GoX2A=";
hash = sourceHash;
};

webui = buildNpmPackage {
Expand Down Expand Up @@ -45,18 +51,21 @@ buildGoModule rec {
runHook postInstall
'';

sourceRoot = "${src.name}/beszel/site";
sourceRoot = "${src.name}/internal/site";

npmDepsHash = "sha256-6J1LwRzwbQyXVBHNgG7k8CQ67JZIDqYreDbgfm6B4w4=";
npmDepsHash = npmHash;
};

sourceRoot = "${src.name}/beszel";
sourceRoot = "${src.name}";

vendorHash = "sha256-Nd2jDlq+tdGrgxU6ZNgj9awAb+G/yDqY1J15dpMcjtw=";
vendorHash = goHash;

# TODO remove when #441125 is merged into master
postPatch = ''substituteInPlace go.mod --replace "go 1.25.1" "go 1.25.0"'';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#441125 is merged into master !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint! I was able to make some final tweaks and make it build!


preBuild = ''
mkdir -p site/dist
cp -r ${webui}/* site/dist
mkdir -p internal/site/dist
cp -r ${webui}/* internal/site/dist
'';

postInstall = ''
Expand Down
Loading