Files
claude-desktop-debian/nix/node-pty.nix
Alexis Williams caa58cae8d feat: add node-pty Nix derivation for terminal support
Build node-pty from source using buildNpmPackage so Claude Desktop's
terminal features (Claude Code) work on NixOS. The derivation handles
three issues with the upstream package:

- Strips macOS-only fsevents reference from package-lock.json so
  npm ci doesn't fail on lock/json mismatch
- Runs both tsc (TypeScript to JS) and node-gyp rebuild (native addon)
- Copies build/Release/pty.node into output since npmInstallHook
  doesn't include native addons

Also wires node-pty into claude-desktop.nix via --node-pty-dir flag
and updates the flake overlay to expose it.

Co-Authored-By: Claude <claude@anthropic.com>
2026-02-28 15:14:33 -08:00

52 lines
1.3 KiB
Nix

{
lib,
buildNpmPackage,
fetchFromGitHub,
python3,
node-gyp,
}:
buildNpmPackage rec {
pname = "node-pty";
version = "1.1.0";
src = fetchFromGitHub {
owner = "microsoft";
repo = "node-pty";
rev = "v${version}";
hash = "sha256-R0QxTw3tNJvW4aEi+GOF0iZhGgI42HTYJih90CdF18I=";
};
npmDepsHash = "sha256-HRv/4NO7CHkPs7ld8lx61n2cty0EhmWVrpH/1Vqh+Nk=";
# node-gyp needs python3 for native compilation
nativeBuildInputs = [ python3 node-gyp ];
# chokidar (dev dep) has an optional dep on fsevents (macOS-only).
# The Nix npm deps fetcher excludes it, so npm ci sees a lock/json
# mismatch. Strip the reference from the lock file to fix the sync.
postPatch = ''
sed -i '/"fsevents"/d' package-lock.json
'';
# Default npmBuildHook only runs "npm run build" (tsc), but we also
# need the native addon. Run both explicitly.
buildPhase = ''
runHook preBuild
npm run build
node-gyp rebuild
runHook postBuild
'';
# npmInstallHook doesn't copy the native addon — do it ourselves
postInstall = ''
cp -r build $out/lib/node_modules/node-pty/
'';
meta = with lib; {
description = "Fork pseudoterminals in Node.JS";
homepage = "https://github.com/microsoft/node-pty";
license = licenses.mit;
platforms = platforms.linux;
};
}