From 00eb03dcd25da50913f4285a26d0175b735bc279 Mon Sep 17 00:00:00 2001 From: Julian Sutter Date: Thu, 18 Dec 2025 21:12:48 -0800 Subject: [PATCH] Add octofriend configuration to flake - Embed octofriend.json5 config directly in flake.nix postInstall - Set OCTOFRIEND_CONFIG_DIR to point to included config - Add comprehensive README with setup and configuration instructions - Keep API keys out of repo for security (users must add keys.json5 locally) --- appflakes/octofriend/README.md | 64 ++++++++++++++++++++++++++++++++++ appflakes/octofriend/flake.nix | 37 ++++++++++++++++++-- 2 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 appflakes/octofriend/README.md diff --git a/appflakes/octofriend/README.md b/appflakes/octofriend/README.md new file mode 100644 index 0000000..8d999df --- /dev/null +++ b/appflakes/octofriend/README.md @@ -0,0 +1,64 @@ +# Octofriend flake for Nix/NixOS + +This flake packages [octofriend](https://github.com/synthetic-lab/octofriend), a CLI coding assistant. + +## Building + +```bash +nix build . +``` + +## Running + +```bash +nix run . +``` + +## Installation + +Add to your NixOS configuration: +```nix +inputs.octofriend.url = "path:/home/jsutter/src/nixos/appflakes/octofriend"; + +# Then in your environment.systemPackages or home.packages: +self.inputs.octofriend.packages.${system}.default +``` + +## Configuration + +The octofriend flake includes default configuration files at `/share/octofriend/config/octofriend.json5`. However, API keys should not be stored in the repository for security reasons. + +### Default Configuration + +The included configuration provides: +- Your name as 'Jules' +- Two model configurations (GLM-4.6 and MiniMax M2) pointing to https://api.synthetic.new +- Specialized models for diff-apply and fix-json operations + +### API Keys + +To configure API keys, create a `keys.json5` file in your configuration directory: +```json5 +{ + 'https://api.synthetic.new/v1': 'your-api-key-here' +} +``` + +When using octofriend, you can either: +1. Place your keys in `~/.config/octofriend/keys.json5` (default location) +2. Set the `OCTOFRIEND_CONFIG_DIR` environment variable to a custom directory containing your files + +This ensures sensitive API keys are not committed to the repository while still providing functional default configuration. + +### Custom Configuration + +If you want to override the default configuration, you can create your own `octofriend.json5` file in your config directory. The wrapper script will check for configuration files in the following order: +1. `$OCTOFRIEND_CONFIG_DIR/octofriend.json5` (if OCTOFRIEND_CONFIG_DIR is set) +2. `~/.config/octofriend/octofriend.json5` +3. Fall back to the included default at `$OCTOFRIEND_PACKAGE_DIR/share/octofriend/config/octofriend.json5` + +## Security Note + +- The `keys.json5` file containing API keys is intentionally NOT included in this flake +- Never commit API keys to any repository +- The included configuration uses placeholder settings and should be customized with your actual model preferences and endpoints \ No newline at end of file diff --git a/appflakes/octofriend/flake.nix b/appflakes/octofriend/flake.nix index cfba23f..14f3347 100644 --- a/appflakes/octofriend/flake.nix +++ b/appflakes/octofriend/flake.nix @@ -37,12 +37,43 @@ postInstall = '' if [ -x "$out/bin/octofriend" ]; then wrapProgram "$out/bin/octofriend" \ - --prefix PATH : ${lib.makeBinPath [ pkgs.git pkgs.openssh ]} + --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. + # 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; { @@ -58,4 +89,4 @@ exePath = "/bin/octofriend"; }; }); -} +} \ No newline at end of file