this patch fixes your error
diff --git a/pack.mjs b/pack.mjs
index 9aed1c2..3dc3255 100644
--- a/pack.mjs
+++ b/pack.mjs
@@ -63,6 +63,8 @@ if (process.platform === 'win32') {
await $`codesign --remove-signature ${executablePath}`.nothrow();
}
+await $`chmod +w ${executablePath}`;
+
await $([
`npx postject ${executablePath} NODE_SEA_BLOB ${path.join(
'build',
This is the final derivation I came up with, does print the help message. but… I haven’t tested it further.
{
fetchFromGitHub,
fetchNpmDeps,
nodejs_22,
npmHooks,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libdragon-docker";
version = "12.0.4";
src = fetchFromGitHub {
owner = "anacierdem";
repo = "libdragon-docker";
tag = "v${finalAttrs.version}";
hash = "sha256-sSibqWh60d0LhuCkAnLwkitFD5XgRejyS3ptbacYjkk=";
};
patches = [ ./allow-write.patch ];
npmDeps = fetchNpmDeps {
name = "${finalAttrs.pname}-npm-deps-${finalAttrs.version}";
inherit (finalAttrs) src;
hash = "sha256-N/p5uexuGoNryx27+nNyDU4z3VkDT2x1FRis2OdA9Js=";
};
nativeBuildInputs = [
nodejs_22
npmHooks.npmConfigHook
];
dontFixup = true;
buildPhase = ''
runHook preBuild
npm run pack ${finalAttrs.version}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mv build/libdragon-linux $out/bin/libdragon
runHook postInstall
'';
})
I used this interactive script, Nix-build-phases: run nix build phases interactively and ran the steps manually one by one, commented out that last part in pack.mjs and ran it from the cli npx postject ..
command which gave the error, can’t write to executable, so I added the chmod +w patch.
Then I found the final binary doesn’t need node_modules, nor is it a nodejs package so I moved to stdenv.mkDerivation instead of buildNpmPackage, and followed the nixpkgs unstable manual nodejs npm section.
Encountered one more seg fault with final binary, but it was working in the interactive build steps after buildPhase (script I linked above) and thus I assumed one of the later phases mainly fixupPhase was the culprit, so disabled it.
other minor things
- using nodejs_22 because the upstream github actions workflows have node version 22
- tag instead of rev in src fetchFromGithub (optional)
- hash instead of sha256 (optional)
- using finalAttrs pattern instead of rec (optional)