This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

nix flake

Nathan Herald (Mar 23, 2026, 11:45 AM +0100) a6f400b9 64010a16

+296 -2
+14
.github/workflows/nix.yml
··· 1 + name: Nix 2 + on: 3 + pull_request: 4 + push: 5 + branches: [main] 6 + 7 + jobs: 8 + build: 9 + runs-on: macos-latest 10 + timeout-minutes: 15 11 + steps: 12 + - uses: actions/checkout@v4 13 + - uses: DeterminateSystems/determinate-nix-action@v3 14 + - run: nix build .#pty
+1
.gitignore
··· 1 1 node_modules/ 2 + result
+14
completions/pty.bash
··· 23 23 names=$(ls "${session_dir}"/*.json 2>/dev/null | xargs -I{} basename {} .json) 24 24 COMPREPLY=($(compgen -W "${names}" -- "${cur}")) 25 25 fi 26 + # Flags per subcommand 27 + if [[ "${cur}" == -* ]]; then 28 + case "${COMP_WORDS[1]}" in 29 + attach|a) COMPREPLY=($(compgen -W "--auto-restart -r" -- "${cur}")) ;; 30 + peek) COMPREPLY=($(compgen -W "--follow -f --plain" -- "${cur}")) ;; 31 + send) COMPREPLY=($(compgen -W "--seq --with-delay" -- "${cur}")) ;; 32 + restart) COMPREPLY=($(compgen -W "--yes -y" -- "${cur}")) ;; 33 + esac 34 + fi 35 + ;; 36 + list|ls) 37 + if [[ "${cur}" == -* ]]; then 38 + COMPREPLY=($(compgen -W "--json" -- "${cur}")) 39 + fi 26 40 ;; 27 41 run) 28 42 # After --, fall back to default file completion
+69
completions/pty.fish
··· 1 + # Fish completion for pty 2 + # Persistent terminal sessions with detach/attach support 3 + # Place in ~/.config/fish/completions/ or install via: npm run install-completions 4 + 5 + function __pty_sessions 6 + set -l session_dir "$PTY_SESSION_DIR" 7 + if test -z "$session_dir" 8 + set session_dir "$HOME/.local/state/pty" 9 + end 10 + if test -d "$session_dir" 11 + for f in $session_dir/*.json 12 + if test -f "$f" 13 + basename $f .json 14 + end 15 + end 16 + end 17 + end 18 + 19 + function __pty_needs_command 20 + set -l cmd (commandline -opc) 21 + test (count $cmd) -eq 1 22 + end 23 + 24 + function __pty_using_command 25 + set -l cmd (commandline -opc) 26 + test (count $cmd) -ge 2; and test "$cmd[2]" = "$argv[1]" 27 + end 28 + 29 + # Disable file completions by default 30 + complete -c pty -f 31 + 32 + # Subcommands 33 + complete -c pty -n __pty_needs_command -a run -d 'Create a session and attach' 34 + complete -c pty -n __pty_needs_command -a attach -d 'Attach to an existing session' 35 + complete -c pty -n __pty_needs_command -a peek -d 'Print current screen or follow output' 36 + complete -c pty -n __pty_needs_command -a send -d 'Send text or keys to a session' 37 + complete -c pty -n __pty_needs_command -a kill -d 'Kill or remove a session' 38 + complete -c pty -n __pty_needs_command -a list -d 'List active sessions' 39 + complete -c pty -n __pty_needs_command -a restart -d 'Restart a session' 40 + complete -c pty -n __pty_needs_command -a help -d 'Show usage information' 41 + 42 + # run: flags and file completion for the command argument 43 + complete -c pty -n '__pty_using_command run' -s d -l detach -d 'Create in background' 44 + complete -c pty -n '__pty_using_command run' -s a -l attach -d 'Attach if already running' 45 + complete -c pty -n '__pty_using_command run' -F 46 + 47 + # attach: session names and flags 48 + complete -c pty -n '__pty_using_command attach' -a '(__pty_sessions)' -d 'Session' 49 + complete -c pty -n '__pty_using_command attach' -s r -l auto-restart -d 'Auto-restart if exited' 50 + 51 + # peek: session names and flags 52 + complete -c pty -n '__pty_using_command peek' -a '(__pty_sessions)' -d 'Session' 53 + complete -c pty -n '__pty_using_command peek' -s f -l follow -d 'Follow output read-only' 54 + complete -c pty -n '__pty_using_command peek' -l plain -d 'Output plain text without ANSI' 55 + 56 + # send: session names and flags 57 + complete -c pty -n '__pty_using_command send' -a '(__pty_sessions)' -d 'Session' 58 + complete -c pty -n '__pty_using_command send' -l seq -d 'Send a sequence item' -r 59 + complete -c pty -n '__pty_using_command send' -l with-delay -d 'Delay between --seq items (seconds)' -r 60 + 61 + # kill: session names 62 + complete -c pty -n '__pty_using_command kill' -a '(__pty_sessions)' -d 'Session' 63 + 64 + # restart: session names and flags 65 + complete -c pty -n '__pty_using_command restart' -a '(__pty_sessions)' -d 'Session' 66 + complete -c pty -n '__pty_using_command restart' -s y -l yes -d 'Skip confirmation' 67 + 68 + # list: flags 69 + complete -c pty -n '__pty_using_command list' -l json -d 'Output as JSON'
+5
completions/pty.zsh
··· 21 21 'send:Send text or keys to a session' 22 22 'kill:Kill or remove a session' 23 23 'list:List active sessions' 24 + 'ls:List active sessions' 24 25 'restart:Restart an exited session' 25 26 'help:Show usage information' 26 27 ) ··· 59 60 _arguments \ 60 61 '(-y --yes)'{-y,--yes}'[Skip confirmation for running sessions]' \ 61 62 '1:session:_pty_sessions' 63 + ;; 64 + list|ls) 65 + _arguments \ 66 + '--json[Output as JSON]' 62 67 ;; 63 68 run) 64 69 # After --, fall back to normal (command + file) completion
+27
flake.lock
··· 1 + { 2 + "nodes": { 3 + "nixpkgs": { 4 + "locked": { 5 + "lastModified": 1773840656, 6 + "narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=", 7 + "owner": "NixOS", 8 + "repo": "nixpkgs", 9 + "rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512", 10 + "type": "github" 11 + }, 12 + "original": { 13 + "owner": "NixOS", 14 + "ref": "nixpkgs-unstable", 15 + "repo": "nixpkgs", 16 + "type": "github" 17 + } 18 + }, 19 + "root": { 20 + "inputs": { 21 + "nixpkgs": "nixpkgs" 22 + } 23 + } 24 + }, 25 + "root": "root", 26 + "version": 7 27 + }
+95
flake.nix
··· 1 + { 2 + description = "pty - Persistent terminal sessions with detach/attach support"; 3 + 4 + inputs = { 5 + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 6 + }; 7 + 8 + outputs = { self, nixpkgs }: 9 + let 10 + # Systems we support 11 + supportedSystems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ]; 12 + 13 + # Helper to create outputs for each system 14 + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; 15 + 16 + # Get pkgs for a given system 17 + pkgsFor = system: nixpkgs.legacyPackages.${system}; 18 + in 19 + { 20 + packages = forAllSystems (system: 21 + let 22 + pkgs = pkgsFor system; 23 + 24 + pty = pkgs.buildNpmPackage { 25 + pname = "pty"; 26 + version = "0.1.0"; 27 + 28 + src = ./.; 29 + 30 + # Generated from package-lock.json. 31 + # Regenerate with: nix run nixpkgs#prefetch-npm-deps -- package-lock.json 32 + npmDepsHash = "sha256-DKmpmKWDnZxcTgzhIt2iFniRQLp1YPxxRHhEI/vZNaU="; 33 + 34 + # node-pty has native code that needs these at build time 35 + nativeBuildInputs = with pkgs; [ python3 pkg-config ]; 36 + buildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ 37 + pkgs.apple-sdk_15 38 + ]; 39 + 40 + # No compile step — Node runs TypeScript directly via type stripping. 41 + dontNpmBuild = true; 42 + 43 + # Install outside of node_modules so Node's TypeScript stripping works. 44 + # (Node refuses to strip types for files under node_modules/) 45 + installPhase = '' 46 + runHook preInstall 47 + 48 + mkdir -p $out/lib/pty 49 + cp -r . $out/lib/pty 50 + 51 + # node-pty's spawn-helper must be executable 52 + chmod +x $out/lib/pty/node_modules/node-pty/prebuilds/*/spawn-helper 2>/dev/null || true 53 + 54 + mkdir -p $out/bin 55 + ln -s $out/lib/pty/bin/pty $out/bin/pty 56 + chmod +x $out/bin/pty 57 + substituteInPlace $out/bin/pty \ 58 + --replace-fail "#!/usr/bin/env node" "#!${pkgs.nodejs}/bin/node" 59 + 60 + installShellCompletion --bash completions/pty.bash 61 + installShellCompletion --zsh completions/pty.zsh 62 + installShellCompletion --fish completions/pty.fish 63 + 64 + runHook postInstall 65 + ''; 66 + 67 + meta = with pkgs.lib; { 68 + description = "Persistent terminal sessions with detach/attach support"; 69 + homepage = "https://github.com/myobie/pty"; 70 + license = licenses.mit; 71 + mainProgram = "pty"; 72 + }; 73 + }; 74 + in 75 + { 76 + default = pty; 77 + inherit pty; 78 + } 79 + ); 80 + 81 + # `nix develop` — gives you node, npm, and project deps for hacking 82 + devShells = forAllSystems (system: 83 + let pkgs = pkgsFor system; 84 + in { 85 + default = pkgs.mkShell { 86 + packages = with pkgs; [ 87 + nodejs_22 88 + python3 # for node-pty native build 89 + pkg-config 90 + ]; 91 + }; 92 + } 93 + ); 94 + }; 95 + }
+32
githooks/pre-commit
··· 1 + #!/bin/sh 2 + # Verify npmDepsHash in flake.nix matches package-lock.json. 3 + # Skips if nix isn't installed or if package-lock.json isn't staged. 4 + 5 + set -e 6 + 7 + # Only check if package-lock.json is being committed 8 + if ! git diff --cached --name-only | grep -q '^package-lock\.json$'; then 9 + exit 0 10 + fi 11 + 12 + # Skip if nix isn't available 13 + if ! command -v nix >/dev/null 2>&1; then 14 + exit 0 15 + fi 16 + 17 + # Skip if there's no flake.nix 18 + if [ ! -f flake.nix ]; then 19 + exit 0 20 + fi 21 + 22 + expected=$(nix run nixpkgs#prefetch-npm-deps -- package-lock.json 2>/dev/null) || exit 0 23 + current=$(grep 'npmDepsHash' flake.nix | sed 's/.*"\(.*\)".*/\1/') 24 + 25 + if [ "$expected" != "$current" ]; then 26 + echo "error: npmDepsHash in flake.nix is stale." 27 + echo " current: $current" 28 + echo " expected: $expected" 29 + echo "" 30 + echo "Run 'npm install' to update it, then stage flake.nix." 31 + exit 1 32 + fi
-1
package-lock.json
··· 7 7 "": { 8 8 "name": "ptym", 9 9 "version": "0.1.0", 10 - "hasInstallScript": true, 11 10 "dependencies": { 12 11 "@xterm/addon-serialize": "^0.14.0", 13 12 "@xterm/headless": "^6.0.0",
+1 -1
package.json
··· 10 10 "./testing": "./src/testing/index.ts" 11 11 }, 12 12 "scripts": { 13 - "postinstall": "chmod +x node_modules/node-pty/prebuilds/darwin-*/spawn-helper 2>/dev/null || true", 13 + "prepare": "git config core.hooksPath githooks 2>/dev/null || true; chmod +x node_modules/node-pty/prebuilds/darwin-*/spawn-helper 2>/dev/null || true; sh scripts/update-nix-hash.sh 2>/dev/null || true", 14 14 "install-completions": "sh scripts/install-completions.sh", 15 15 "typecheck": "tsc", 16 16 "test": "vitest run",
+10
scripts/install-completions.sh
··· 24 24 break 25 25 fi 26 26 done 27 + 28 + # Fish completions 29 + for dir in "$HOME/.config/fish/completions" /opt/homebrew/share/fish/vendor_completions.d /usr/local/share/fish/vendor_completions.d; do 30 + if [ -d "$dir" ] || [ -d "$(dirname "$dir")" -a "$(basename "$dir")" = "completions" ]; then 31 + mkdir -p "$dir" 32 + ln -sf "$COMPLETIONS_DIR/pty.fish" "$dir/pty.fish" 33 + echo "Fish completions installed: $dir/pty.fish" 34 + break 35 + fi 36 + done
+28
scripts/update-nix-hash.sh
··· 1 + #!/bin/sh 2 + # Update the npmDepsHash in flake.nix after npm install. 3 + # Requires nix to be installed — silently skips if unavailable. 4 + 5 + set -e 6 + 7 + SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 8 + FLAKE="$SCRIPT_DIR/../flake.nix" 9 + 10 + if [ ! -f "$FLAKE" ]; then 11 + exit 0 12 + fi 13 + 14 + if ! command -v nix >/dev/null 2>&1; then 15 + exit 0 16 + fi 17 + 18 + LOCK="$SCRIPT_DIR/../package-lock.json" 19 + if [ ! -f "$LOCK" ]; then 20 + exit 0 21 + fi 22 + 23 + hash=$(nix run nixpkgs#prefetch-npm-deps -- "$LOCK" 2>/dev/null) || exit 0 24 + 25 + if [ -n "$hash" ]; then 26 + sed -i '' "s|npmDepsHash = \".*\"|npmDepsHash = \"$hash\"|" "$FLAKE" 27 + echo "Updated npmDepsHash in flake.nix" 28 + fi