-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
98 lines (81 loc) · 3.02 KB
/
Copy pathflake.nix
File metadata and controls
98 lines (81 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
description = "pty - Persistent terminal sessions with detach/attach support";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }:
let
# Systems we support
supportedSystems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
# Helper to create outputs for each system
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Get pkgs for a given system
pkgsFor = system: nixpkgs.legacyPackages.${system};
in
{
packages = forAllSystems (system:
let
pkgs = pkgsFor system;
pty = pkgs.buildNpmPackage {
pname = "pty";
version = "0.1.0";
src = ./.;
# Generated from package-lock.json.
# Regenerate with: nix run nixpkgs#prefetch-npm-deps -- package-lock.json
npmDepsHash = "sha256-tpcQNvod3UWOkY0/QT5RWUH2y9fP9TygV4NmnZ3LKpw=";
# node-pty has native code that needs these at build time
nativeBuildInputs = with pkgs; [ python3 pkg-config ];
buildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
pkgs.apple-sdk_15
];
buildPhase = ''
runHook preBuild
npm run build
runHook postBuild
'';
# Install outside of node_modules so Node's TypeScript stripping works.
# (Node refuses to strip types for files under node_modules/)
installPhase = ''
runHook preInstall
mkdir -p $out/lib/pty
cp -r . $out/lib/pty
# node-pty's spawn-helper must be executable
chmod +x $out/lib/pty/node_modules/node-pty/prebuilds/*/spawn-helper 2>/dev/null || true
mkdir -p $out/bin
ln -s $out/lib/pty/bin/pty $out/bin/pty
chmod +x $out/bin/pty
substituteInPlace $out/bin/pty \
--replace-fail "#!/usr/bin/env node" "#!${pkgs.nodejs}/bin/node"
installShellCompletion --bash completions/pty.bash
installShellCompletion --zsh completions/pty.zsh
installShellCompletion --fish completions/pty.fish
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Persistent terminal sessions with detach/attach support";
homepage = "https://github.com/compoundingtech/pty";
license = licenses.mit;
mainProgram = "pty";
};
};
in
{
default = pty;
inherit pty;
}
);
# `nix develop` — gives you node, npm, and project deps for hacking
devShells = forAllSystems (system:
let pkgs = pkgsFor system;
in {
default = pkgs.mkShell {
packages = with pkgs; [
nodejs_22
python3 # for node-pty native build
pkg-config
];
};
}
);
};
}