This repository has no description
0

Configure Feed

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

superconfig / tools / pi / flake-module.nix
3.0 kB 79 lines
1{ self, ... }: 2{ 3 perSystem = 4 { pkgs, system, ... }: 5 let 6 piPkg = self.legacyPackages.${system}.llm.pi; 7 8 # Pre-install pi plugins into a fake npm global prefix 9 pluginPrefixRaw = 10 pkgs.runCommand "pi-plugins-raw" 11 { 12 nativeBuildInputs = [ 13 pkgs.nodejs 14 pkgs.cacert 15 ]; 16 outputHashMode = "recursive"; 17 outputHashAlgo = "sha256"; 18 outputHash = "sha256-QZSVCJ0XirRz56v6ogxaB37c0bI8+OGEjrnqCFr/YI8="; 19 impureEnvVars = [ 20 "http_proxy" 21 "https_proxy" 22 ]; 23 SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; 24 } 25 '' 26 export HOME=$TMPDIR 27 export npm_config_prefix=$out 28 npm install -g pi-hooks shitty-extensions 29 ''; 30 31 # Patch shitty-extensions: 32 # - Remove the resistance extension (annoying terminator quote widget) 33 # - Rebind ultrathink ctrl+u -> ctrl+shift+u (conflicts with deleteToLineStart) 34 # - Rebind speedreading ctrl+r -> ctrl+shift+r (conflicts with renameSession) 35 pluginPrefix = pkgs.runCommand "pi-plugins" { } '' 36 cp -a ${pluginPrefixRaw} $out 37 chmod -R u+w $out 38 pkg=$out/lib/node_modules/shitty-extensions/package.json 39 ${pkgs.jq}/bin/jq '.pi.extensions |= map(select(contains("resistance") | not))' "$pkg" > "$pkg.tmp" 40 mv "$pkg.tmp" "$pkg" 41 42 # Fix keybinding conflicts in extension source 43 ${pkgs.gnused}/bin/sed -i 's/"ctrl+u"/"ctrl+shift+u"/' $out/lib/node_modules/shitty-extensions/extensions/ultrathink.ts 44 ${pkgs.gnused}/bin/sed -i 's/"ctrl+r"/"ctrl+shift+r"/' $out/lib/node_modules/shitty-extensions/extensions/speedreading.ts 45 ''; 46 in 47 { 48 packages.pi = self.wrapLib.makeWrapper { 49 pkgs = pkgs; 50 package = piPkg; 51 runtimeInputs = [ pkgs.nodejs ]; 52 wrapper = 53 { exePath, ... }: 54 '' 55 set -efu 56 export npm_config_prefix="${pluginPrefix}" 57 58 # Ensure settings.json has our plugins listed 59 SETTINGS_DIR="''${PI_CODING_AGENT_DIR:-$HOME/.pi/agent}" 60 SETTINGS_FILE="$SETTINGS_DIR/settings.json" 61 mkdir -p "$SETTINGS_DIR" 62 63 # Add packages to settings if not already present 64 if [ ! -f "$SETTINGS_FILE" ]; then 65 echo '{"packages":["npm:pi-hooks","npm:shitty-extensions"]}' > "$SETTINGS_FILE" 66 else 67 for pkg in "npm:pi-hooks" "npm:shitty-extensions"; do 68 if ! grep -q "$pkg" "$SETTINGS_FILE"; then 69 ${pkgs.jq}/bin/jq --arg p "$pkg" '.packages = ((.packages // []) + [$p] | unique)' "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp" 70 mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE" 71 fi 72 done 73 fi 74 75 exec ${exePath} "$@" 76 ''; 77 }; 78 }; 79}