Maybe actually fix builds

This commit is contained in:
StealthBadger747
2025-07-15 12:32:54 -07:00
committed by Aarnav Tale
parent 7a34a01dd0
commit 8b3d0e9bb6
3 changed files with 53 additions and 25 deletions
+14 -23
View File
@@ -5,48 +5,38 @@
nodejs_22,
pnpm_10,
stdenv,
go,
hp_ssh_wasm,
...
}:
let
wasmExecJs =
if builtins.pathExists "${go}/share/go/lib/wasm/wasm_exec.js"
then "${go}/share/go/lib/wasm/wasm_exec.js"
else if builtins.pathExists "${go}/lib/wasm/wasm_exec.js"
then "${go}/lib/wasm/wasm_exec.js"
else "${go}/share/go/misc/wasm/wasm_exec.js";
pkg = builtins.fromJSON (builtins.readFile ../package.json);
pname = pkg.name;
version = pkg.version;
src = ../.;
in
stdenv.mkDerivation (finalAttrs: {
pname = "headplane";
version = (builtins.fromJSON (builtins.readFile ../package.json)).version;
src = ../.;
pname = pname;
version = version;
src = src;
nativeBuildInputs = [
makeWrapper
nodejs_22
pnpm_10.configHook
git
go
];
dontCheckForBrokenSymlinks = true;
pnpmDeps = pnpm_10.fetchDeps {
inherit (finalAttrs) pname version src;
inherit pname version src;
hash = "sha256-GNSpFqPobX6MDPUXxz2XwdZ2Wt7boN8aok52pGgpGoM=";
};
buildPhase = ''
runHook preBuild
# Build the Go WASM binary
export GOOS=js
export GOARCH=wasm
go build -o app/hp_ssh.wasm ./cmd/hp_ssh
# Copy wasm_exec.js to the app directory (from Nix store)
cp ${wasmExecJs} app/wasm_exec.js
cp ${hp_ssh_wasm}/hp_ssh.wasm app/hp_ssh.wasm
cp ${hp_ssh_wasm}/wasm_exec.js app/wasm_exec.js
pnpm build
runHook postBuild
'';
@@ -55,10 +45,11 @@ stdenv.mkDerivation (finalAttrs: {
runHook preInstall
mkdir -p $out/{bin,share/headplane}
cp -r build $out/share/headplane/
cp -r node_modules $out/share/headplane/
sed -i "s;$PWD;../..;" $out/share/headplane/build/server/index.js
makeWrapper ${lib.getExe nodejs_22} $out/bin/headplane \
--chdir $out/share/headplane \
--add-flags $out/share/headplane/build/server/index.js
--chdir $out/share/headplane \
--add-flags $out/share/headplane/build/server/index.js
runHook postInstall
'';
})