Skip to content

Instantly share code, notes, and snippets.

@mausch
Created June 28, 2026 14:45
Show Gist options
  • Select an option

  • Save mausch/183e73e7e72975e271bc078b7e2829cd to your computer and use it in GitHub Desktop.

Select an option

Save mausch/183e73e7e72975e271bc078b7e2829cd to your computer and use it in GitHub Desktop.
oh-my-pi
{
description = "Nix flake for can1357/oh-my-pi";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
lib = pkgs.lib;
pname = "oh-my-pi";
version = "16.2.2-unstable-2026-06-28";
rev = "4373dde48a2887df68c0327746891d103b92475c";
src = pkgs.fetchFromGitHub {
owner = "can1357";
repo = "oh-my-pi";
inherit rev;
hash = "sha256-d0FEXWzKp/RiaMewm7wiO7TZoITnRuH6q4WjDDbXC3c=";
};
bun = pkgs.stdenvNoCC.mkDerivation {
pname = "bun";
version = "1.3.14";
src = pkgs.fetchzip {
url = "https://github.com/oven-sh/bun/releases/download/bun-v1.3.14/bun-linux-x64.zip";
hash = "sha256-YyGDD7f0JlmiO2G3LY80p/oMUpWXcoC7x7LW/gU/LmU=";
stripRoot = false;
};
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
buildInputs = [ pkgs.stdenv.cc.cc.lib ];
installPhase = ''
runHook preInstall
install -Dm755 $src/bun-linux-x64/bun $out/bin/bun
runHook postInstall
'';
};
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
inherit pname version src;
hash = "sha256-4dnISISWFEgVHHz4o8BxBFGwzPgV28UH/zd6U7IyoYc=";
};
rust = pkgs.rust-bin.nightly."2026-04-29".default.override {
extensions = [
"clippy"
"rustfmt"
];
};
bunDeps = pkgs.stdenvNoCC.mkDerivation {
pname = "${pname}-bun-deps";
inherit version src;
nativeBuildInputs = [ bun ];
dontConfigure = true;
dontFixup = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-viOYMDb5csRrHO83gq09wi+FCHYIJz8PxC6lDmn5Mb0=";
buildPhase = ''
runHook preBuild
export HOME=$TMPDIR
export BUN_INSTALL_CACHE_DIR=$TMPDIR/bun-cache
bun install --frozen-lockfile --ignore-scripts
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -R node_modules $out/node_modules
while IFS= read -r dir; do
target=$out/''${dir#./}
mkdir -p "$(dirname "$target")"
cp -R "$dir" "$target"
done < <(find packages python -type d -name node_modules 2>/dev/null)
runHook postInstall
'';
};
nativeLibPath = lib.makeLibraryPath [
pkgs.libxkbcommon
pkgs.wayland
pkgs.libx11
pkgs.libxcb
];
oh-my-pi = pkgs.stdenv.mkDerivation {
inherit
pname
version
src
cargoDeps
;
nativeBuildInputs = [
bun
pkgs.makeWrapper
pkgs.nodejs
pkgs.pkg-config
pkgs.python3
pkgs.rustPlatform.cargoSetupHook
rust
];
buildInputs = [
pkgs.libxkbcommon
pkgs.openssl
pkgs.wayland
pkgs.libx11
pkgs.libxcb
];
postPatch = ''
patchShebangs scripts packages python || true
'';
configurePhase = ''
runHook preConfigure
rm -rf node_modules
cp -R ${bunDeps}/node_modules .
chmod -R u+w node_modules
patchShebangs node_modules/.bin node_modules/@napi-rs/cli/dist
for dir in ${bunDeps}/packages/*/node_modules; do
[ -e "$dir" ] || continue
target="packages/$(basename "$(dirname "$dir")")/node_modules"
mkdir -p "$(dirname "$target")"
cp -R "$dir" "$target"
chmod -R u+w "$target"
done
export HOME=$TMPDIR
export BUN_INSTALL_CACHE_DIR=$TMPDIR/bun-cache
export npm_config_nodedir=${pkgs.nodejs}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
bun --cwd=packages/natives run build
bun --cwd=packages/coding-agent run gen:docs
bun --cwd=packages/collab-web run gen:tool-views
bun --cwd=packages/coding-agent run gen:bundle
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/oh-my-pi $out/bin
cp -R . $out/lib/oh-my-pi
makeWrapper ${bun}/bin/bun $out/bin/omp \
--add-flags "$out/lib/oh-my-pi/packages/coding-agent/src/cli.ts" \
--prefix LD_LIBRARY_PATH : ${nativeLibPath}
runHook postInstall
'';
meta = {
description = "AI coding agent for the terminal";
homepage = "https://github.com/can1357/oh-my-pi";
license = lib.licenses.mit;
mainProgram = "omp";
platforms = lib.platforms.linux;
};
};
in
{
packages = {
default = oh-my-pi;
oh-my-pi = oh-my-pi;
};
apps.default = flake-utils.lib.mkApp {
drv = oh-my-pi;
exePath = "/bin/omp";
};
devShells.default = pkgs.mkShell {
packages = [
bun
pkgs.nodejs
pkgs.pkg-config
pkgs.python3
rust
];
inputsFrom = [ oh-my-pi ];
};
formatter = pkgs.nixfmt-rfc-style;
}
);
}
@mausch

mausch commented Jun 28, 2026

Copy link
Copy Markdown
Author

https://github.com/can1357/oh-my-pi

nix run --refresh --no-write-lock-file git+https://gist.github.com/mausch/183e73e7e72975e271bc078b7e2829cd.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment