nixos/appflakes/octofriend/flake.nix
2026-02-16 21:01:13 +00:00

92 lines
No EOL
2.8 KiB
Nix
Executable file

{
description = "Octofriend (synthetic-lab/octofriend) packaged for Nix/NixOS";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Upstream source (not a flake)
octofriend = {
url = "github:synthetic-lab/octofriend";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, octofriend }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
in
{
packages.default = pkgs.buildNpmPackage {
pname = "octofriend";
version = "git-${builtins.substring 0 7 (octofriend.rev or "unknown")}";
src = octofriend;
# First build will fail telling you the correct value. Paste it here.
npmDepsHash = "sha256-luAdTozvb0MTuh+xa5qhZPH8YflF9R4GtREAaR8m6Y8=";
# Ensure a modern node (octofriend is a Node CLI). :contentReference[oaicite:1]{index=1}
nodejs = pkgs.nodejs_22;
nativeBuildInputs = [ pkgs.makeWrapper ];
# If octofriend shells out to git/ssh/etc, keep PATH sane.
postInstall = ''
if [ -x "$out/bin/octofriend" ]; then
wrapProgram "$out/bin/octofriend" \
--prefix PATH : ${lib.makeBinPath [ pkgs.git pkgs.openssh ]} \
--set OCTOFRIEND_CONFIG_DIR "$out/share/octofriend/config"
fi
# Provide the short alias if upstream didn't already.
if [ -x "$out/bin/octofriend" ] && [ ! -e "$out/bin/octo" ]; then
ln -s "$out/bin/octofriend" "$out/bin/octo"
fi
# Install the config file
mkdir -p "$out/share/octofriend/config"
cat << 'EOF' > "$out/share/octofriend/config/octofriend.json5"
{
yourName: 'Jules',
models: [
{
model: 'hf:zai-org/GLM-4.6',
nickname: 'GLM-4.6 (Synthetic)',
context: 131072,
baseUrl: 'https://api.synthetic.new/v1',
},
{
model: 'hf:MiniMaxAI/MiniMax-M2',
nickname: 'MiniMax M2 (Synthetic)',
context: 98304,
baseUrl: 'https://api.synthetic.new/v1',
},
],
defaultApiKeyOverrides: {},
diffApply: {
baseUrl: 'https://api.synthetic.new/v1',
model: 'hf:syntheticlab/diff-apply',
},
fixJson: {
baseUrl: 'https://api.synthetic.new/v1',
model: 'hf:syntheticlab/fix-json',
},
}
EOF
'';
meta = with lib; {
description = "Octofriend CLI coding assistant";
homepage = "https://github.com/synthetic-lab/octofriend";
license = licenses.mit;
mainProgram = "octofriend";
};
};
apps.default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
exePath = "/bin/octofriend";
};
});
}