meshtastic-web: build from source (#471080)

This commit is contained in:
Pol Dellaiera
2025-12-20 05:10:43 +00:00
committed by GitHub
+48 -8
View File
@@ -1,23 +1,63 @@
{
stdenv,
lib,
fetchurl,
stdenv,
fetchFromGitHub,
pnpm_9,
fetchPnpmDeps,
pnpmConfigHook,
nodejs,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "meshtastic-web";
version = "2.6.7";
src = fetchurl {
url = "https://github.com/meshtastic/web/releases/download/v${finalAttrs.version}/build.tar";
hash = "sha256-o09DYKBIZUOmmN4g3lM1V0kudjq0Wfwn/OqV0ElRRO0=";
src = fetchFromGitHub {
owner = "meshtastic";
repo = "web";
tag = "v${finalAttrs.version}";
hash = "sha256-71/Wr/b42fknVCdeO99AI4ZpJk8Smkse/TFisKLzBCQ=";
fetchSubmodules = true;
leaveDotGit = true;
postFetch = ''
cd "$out"
git rev-parse --short HEAD > $out/COMMIT
find "$out" -name .git -print0 | xargs -0 rm -rf
'';
};
sourceRoot = ".";
pnpmWorkspaces = [ "*" ];
pnpmRoot = "packages/web";
pnpmDeps = fetchPnpmDeps {
pnpm = pnpm_9;
inherit (finalAttrs)
pname
version
src
pnpmWorkspaces
;
fetcherVersion = 2;
hash = "sha256-p8AdAYqaHoKaWirNy9uPLs/kRDVNDcXBJQ1y29MVAA0=";
};
nativeBuildInputs = [
pnpm_9
pnpmConfigHook
nodejs
];
preConfigure = ''
substituteInPlace packages/web/vite.config.ts \
--replace-fail "hash = \"DEV\"" "hash = \"$(cat COMMIT)\"" \
--replace-fail "version = \"v0.0.0\"" "version = \"${finalAttrs.version}\""
'';
buildPhase = ''
runHook preBuild
gzip -dr .
pushd packages/web
pnpm install
pnpm run build
runHook postBuild
'';
@@ -26,7 +66,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook preInstall
mkdir -p $out
cp -ar . $out/
cp -ar dist/. $out/
runHook postInstall
'';