Integrate pi

This commit is contained in:
Martin Pander
2026-07-23 10:48:35 +02:00
parent 8f0ad7ba77
commit 5ed9fdc4bd
15 changed files with 1192 additions and 102 deletions

View File

@@ -18,6 +18,7 @@
./nvim.nix
./task.nix
./opencode.nix
./pi.nix
];
config = {

View File

@@ -26,6 +26,11 @@ in
default = false;
description = "Enable pi";
};
pi.workMode = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Apply work machine (WSL NixOS) specific pi patches";
};
bubblewrap.enable = lib.mkOption {
type = lib.types.bool;
default = pkgs.stdenv.isLinux;
@@ -64,7 +69,33 @@ in
(lib.optional cfg.claude-code.enable pkgs.unstable.claude-code) ++
(lib.optional cfg.opencode.enable pkgs.unstable.opencode) ++
(lib.optional cfg.gemini-cli.enable pkgs.unstable.gemini-cli) ++
(lib.optional cfg.pi.enable inputs.llm-agents.packages.${pkgs.stdenv.hostPlatform.system}.pi) ++
(lib.optional cfg.pi.enable (
let
pi = inputs.llm-agents.packages.${pkgs.stdenv.hostPlatform.system}.pi;
in
if cfg.pi.workMode then
# Work machine runs WSL NixOS, which needs the checks disabled and the
# Bun binary's ELF interpreter patched to the correct dynamic linker.
pi.overrideAttrs (oldAttrs: {
doInstallCheck = false;
# Run patchelf after the package is installed/fixed up by nix
postFixup = (oldAttrs.postFixup or "") + ''
# 1. Target the actual Bun binary inside libexec, not the shell wrapper in bin/
TARGET_BIN="$out/libexec/pi/pi"
if [ -f "$TARGET_BIN" ]; then
# 2. Make it writable in the build store so patchelf can edit it
chmod +w "$TARGET_BIN"
# 3. Running patchelf to set the interpreter forces it to rebuild the ELF headers
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$TARGET_BIN"
fi
'';
})
else
pi
)) ++
(lib.optional (cfg.bubblewrap.enable && pkgs.stdenv.isLinux) pkgs.unstable.bubblewrap);
})
];

View File

@@ -56,6 +56,7 @@
ignores = [
".direnv/"
".envrc"
".pi/"
];
};

View File

@@ -58,6 +58,7 @@ in
nvim-lspconfig
lspkind-nvim
# opencode-nvim
pi-nvim
bullets-vim
nvim-dap
nvim-nio

25
modules/home/pi.nix Normal file
View File

@@ -0,0 +1,25 @@
{ config, lib, ... }:
let
cfg = config.dot.pi;
piPath = "${config.dot.dotfilesPath}/modules/pi/agent";
in
{
options.dot.pi = {
enable = lib.mkEnableOption "managed pi coding agent configuration" // {
default = true;
};
};
config = lib.mkIf cfg.enable {
# Out-of-store symlinks so the files stay editable without a nix rebuild.
# Only the managed files are linked; pi's runtime files (auth.json,
# sessions/, models-store.json) are left untouched in ~/.pi/agent.
home.file = {
".pi/agent/settings.json".source =
config.lib.file.mkOutOfStoreSymlink "${piPath}/settings.json";
".pi/agent/extensions".source =
config.lib.file.mkOutOfStoreSymlink "${piPath}/extensions";
};
};
}