Fix Nix Build (#57)

* fix: fix nix build

* refactor: fix cargo script

* fix: rust version

* refactor: fix desktop app build
This commit is contained in:
Catriel Müller
2026-01-29 11:13:58 +01:00
committed by GitHub
parent 80db9c327f
commit 29deeb9985
20 changed files with 139 additions and 122 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ jobs:
updaterJsonPreferNsis: true
releaseId: ${{ needs.publish.outputs.release }}
tagName: ${{ needs.publish.outputs.tag }}
releaseAssetNamePattern: opencode-desktop-[platform]-[arch][ext]
releaseAssetNamePattern: kilo-desktop-[platform]-[arch][ext]
releaseDraft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+32 -17
View File
@@ -1,5 +1,5 @@
{
description = "OpenCode development flake";
description = "Kilo development flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
@@ -36,34 +36,49 @@
node_modules = pkgs.callPackage ./nix/node_modules.nix {
inherit rev;
};
opencode = pkgs.callPackage ./nix/opencode.nix {
kilo = pkgs.callPackage ./nix/kilo.nix {
inherit node_modules;
};
desktop = pkgs.callPackage ./nix/desktop.nix {
inherit opencode;
inherit kilo;
};
# nixpkgs cpu naming to bun cpu naming
cpuMap = { x86_64 = "x64"; aarch64 = "arm64"; };
cpuMap = {
x86_64 = "x64";
aarch64 = "arm64";
};
# matrix of node_modules builds - these will always fail due to fakeHash usage
# but allow computation of the correct hash from any build machine for any cpu/os
# see the update-nix-hashes workflow for usage
moduleUpdaters = pkgs.lib.listToAttrs (
pkgs.lib.concatMap (cpu:
map (os: {
name = "${cpu}-${os}_node_modules";
value = node_modules.override {
bunCpu = cpuMap.${cpu};
bunOs = os;
hash = pkgs.lib.fakeHash;
};
}) [ "linux" "darwin" ]
) [ "x86_64" "aarch64" ]
pkgs.lib.concatMap
(
cpu:
map
(os: {
name = "${cpu}-${os}_node_modules";
value = node_modules.override {
bunCpu = cpuMap.${cpu};
bunOs = os;
hash = pkgs.lib.fakeHash;
};
})
[
"linux"
"darwin"
]
)
[
"x86_64"
"aarch64"
]
);
in
{
default = opencode;
inherit opencode desktop;
} // moduleUpdaters
default = kilo;
inherit kilo desktop;
}
// moduleUpdaters
);
};
}
+11 -11
View File
@@ -21,11 +21,11 @@
openssl,
webkitgtk_4_1,
gst_all_1,
opencode,
kilo,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "opencode-desktop";
inherit (opencode)
pname = "kilo-desktop";
inherit (kilo)
version
src
node_modules
@@ -72,7 +72,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
patchShebangs packages/desktop/node_modules
mkdir -p packages/desktop/src-tauri/sidecars
cp ${opencode}/bin/opencode packages/desktop/src-tauri/sidecars/opencode-cli-${stdenv.hostPlatform.rust.rustcTarget}
cp ${kilo}/bin/kilo packages/desktop/src-tauri/sidecars/kilo-cli-${stdenv.hostPlatform.rust.rustcTarget}
'';
# see publish-tauri job in .github/workflows/publish.yml
@@ -86,15 +86,15 @@ rustPlatform.buildRustPackage (finalAttrs: {
# should be removed once binary is renamed or decided otherwise
# darwin output is a .app bundle so no conflict
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
mv $out/bin/OpenCode $out/bin/opencode-desktop
sed -i 's|^Exec=OpenCode$|Exec=opencode-desktop|' $out/share/applications/OpenCode.desktop
mv $out/bin/Kilo $out/bin/kilo-desktop
sed -i 's|^Exec=Kilo$|Exec=kilo-desktop|' $out/share/applications/Kilo.desktop
'';
meta = {
description = "OpenCode Desktop App";
homepage = "https://opencode.ai";
description = "Kilo Desktop App";
homepage = "https://kilo.ai";
license = lib.licenses.mit;
mainProgram = "opencode-desktop";
inherit (opencode.meta) platforms;
mainProgram = "kilo-desktop";
inherit (kilo.meta) platforms;
};
})
})
+10 -10
View File
@@ -13,7 +13,7 @@
node_modules ? callPackage ./node-modules.nix { },
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "opencode";
pname = "kilo";
inherit (node_modules) version src;
inherit node_modules;
@@ -50,10 +50,10 @@ stdenvNoCC.mkDerivation (finalAttrs: {
installPhase = ''
runHook preInstall
install -Dm755 dist/opencode-*/bin/opencode $out/bin/opencode
install -Dm644 schema.json $out/share/opencode/schema.json
install -Dm755 dist/@kilocode/cli-*/bin/kilo $out/bin/kilo
install -Dm644 schema.json $out/share/kilo/schema.json
wrapProgram $out/bin/opencode \
wrapProgram $out/bin/kilo \
--prefix PATH : ${
lib.makeBinPath (
[
@@ -69,9 +69,9 @@ stdenvNoCC.mkDerivation (finalAttrs: {
postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
# trick yargs into also generating zsh completions
installShellCompletion --cmd opencode \
--bash <($out/bin/opencode completion) \
--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
installShellCompletion --cmd kilo \
--bash <($out/bin/kilo completion) \
--zsh <(SHELL=/bin/zsh $out/bin/kilo completion)
'';
nativeInstallCheckInputs = [
@@ -83,14 +83,14 @@ stdenvNoCC.mkDerivation (finalAttrs: {
versionCheckProgramArg = "--version";
passthru = {
jsonschema = "${placeholder "out"}/share/opencode/schema.json";
jsonschema = "${placeholder "out"}/share/kilo/schema.json";
};
meta = {
description = "The open source coding agent";
homepage = "https://opencode.ai/";
homepage = "https://kilo.ai/";
license = lib.licenses.mit;
mainProgram = "opencode";
mainProgram = "kilo";
inherit (node_modules.meta) platforms;
};
})
+1 -1
View File
@@ -18,7 +18,7 @@ let
];
in
stdenvNoCC.mkDerivation {
pname = "opencode-node_modules";
pname = "kilo-node_modules";
version = "${packageJson.version}-${rev}";
src = lib.fileset.toSource {
+1 -1
View File
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url"
*/
export default [
{
name: "opencode-desktop:config",
name: "kilo-desktop:config",
config() {
return {
resolve: {
@@ -2,19 +2,19 @@ import { APIEvent } from "@solidjs/start"
import { DownloadPlatform } from "./types"
const assetNames: Record<string, string> = {
"darwin-aarch64-dmg": "opencode-desktop-darwin-aarch64.dmg",
"darwin-x64-dmg": "opencode-desktop-darwin-x64.dmg",
"windows-x64-nsis": "opencode-desktop-windows-x64.exe",
"linux-x64-deb": "opencode-desktop-linux-amd64.deb",
"linux-x64-appimage": "opencode-desktop-linux-amd64.AppImage",
"linux-x64-rpm": "opencode-desktop-linux-x86_64.rpm",
"darwin-aarch64-dmg": "kilo-desktop-darwin-aarch64.dmg",
"darwin-x64-dmg": "kilo-desktop-darwin-x64.dmg",
"windows-x64-nsis": "kilo-desktop-windows-x64.exe",
"linux-x64-deb": "kilo-desktop-linux-amd64.deb",
"linux-x64-appimage": "kilo-desktop-linux-amd64.AppImage",
"linux-x64-rpm": "kilo-desktop-linux-x86_64.rpm",
} satisfies Record<DownloadPlatform, string>
// Doing this on the server lets us preserve the original name for platforms we don't care to rename for
const downloadNames: Record<string, string> = {
"darwin-aarch64-dmg": "OpenCode Desktop.dmg",
"darwin-x64-dmg": "OpenCode Desktop.dmg",
"windows-x64-nsis": "OpenCode Desktop Installer.exe",
"darwin-aarch64-dmg": "Kilo Desktop.dmg",
"darwin-x64-dmg": "Kilo Desktop.dmg",
"windows-x64-nsis": "Kilo Desktop Installer.exe",
} satisfies { [K in DownloadPlatform]?: string }
export async function GET({ params: { platform } }: APIEvent) {
+1 -1
View File
@@ -6,7 +6,7 @@ const RUST_TARGET = Bun.env.TAURI_ENV_TARGET_TRIPLE
const sidecarConfig = getCurrentSidecar(RUST_TARGET)
const binaryPath = windowsify(`../opencode/dist/${sidecarConfig.ocBinary}/bin/opencode`)
const binaryPath = windowsify(`../opencode/dist/${sidecarConfig.ocBinary}/bin/kilo`) // kilocode_change
await $`cd ../opencode && bun run build --single`
+3 -3
View File
@@ -5,9 +5,9 @@ import { copyBinaryToSidecarFolder, getCurrentSidecar, windowsify } from "./util
const sidecarConfig = getCurrentSidecar()
const dir = "src-tauri/target/opencode-binaries"
const dir = "src-tauri/target/kilo-binaries"
await $`mkdir -p ${dir}`
await $`gh run download ${Bun.env.GITHUB_RUN_ID} -n opencode-cli`.cwd(dir)
await $`gh run download ${Bun.env.GITHUB_RUN_ID} -n kilo-cli`.cwd(dir)
await copyBinaryToSidecarFolder(windowsify(`${dir}/${sidecarConfig.ocBinary}/bin/opencode`))
await copyBinaryToSidecarFolder(windowsify(`${dir}/${sidecarConfig.ocBinary}/bin/kilo`))
+6 -6
View File
@@ -3,27 +3,27 @@ import { $ } from "bun"
export const SIDECAR_BINARIES: Array<{ rustTarget: string; ocBinary: string; assetExt: string }> = [
{
rustTarget: "aarch64-apple-darwin",
ocBinary: "opencode-darwin-arm64",
ocBinary: "@kilocode/cli-darwin-arm64", // kilocode_change
assetExt: "zip",
},
{
rustTarget: "x86_64-apple-darwin",
ocBinary: "opencode-darwin-x64",
ocBinary: "@kilocode/cli-darwin-x64", // kilocode_change
assetExt: "zip",
},
{
rustTarget: "x86_64-pc-windows-msvc",
ocBinary: "opencode-windows-x64",
ocBinary: "@kilocode/cli-windows-x64", // kilocode_change
assetExt: "zip",
},
{
rustTarget: "x86_64-unknown-linux-gnu",
ocBinary: "opencode-linux-x64",
ocBinary: "@kilocode/cli-linux-x64", // kilocode_change
assetExt: "tar.gz",
},
{
rustTarget: "aarch64-unknown-linux-gnu",
ocBinary: "opencode-linux-arm64",
ocBinary: "@kilocode/cli-linux-arm64", // kilocode_change
assetExt: "tar.gz",
},
]
@@ -41,7 +41,7 @@ export function getCurrentSidecar(target = RUST_TARGET) {
export async function copyBinaryToSidecarFolder(source: string, target = RUST_TARGET) {
await $`mkdir -p src-tauri/sidecars`
const dest = windowsify(`src-tauri/sidecars/opencode-cli-${target}`)
const dest = windowsify(`src-tauri/sidecars/kilo-cli-${target}`) // kilocode_change
await $`cp ${source} ${dest}`
console.log(`Copied ${source} to ${dest}`)
+33 -33
View File
@@ -2256,6 +2256,39 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "kilo-desktop"
version = "0.0.0"
dependencies = [
"comrak",
"futures",
"gtk",
"listeners",
"reqwest",
"semver",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-clipboard-manager",
"tauri-plugin-decorum",
"tauri-plugin-dialog",
"tauri-plugin-http",
"tauri-plugin-notification",
"tauri-plugin-opener",
"tauri-plugin-os",
"tauri-plugin-process",
"tauri-plugin-shell",
"tauri-plugin-single-instance",
"tauri-plugin-store",
"tauri-plugin-updater",
"tauri-plugin-window-state",
"tokio",
"uuid",
"webkit2gtk",
"windows 0.61.3",
]
[[package]]
name = "kuchikiki"
version = "0.8.8-speedreader"
@@ -3020,39 +3053,6 @@ dependencies = [
"pathdiff",
]
[[package]]
name = "opencode-desktop"
version = "0.0.0"
dependencies = [
"comrak",
"futures",
"gtk",
"listeners",
"reqwest",
"semver",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-clipboard-manager",
"tauri-plugin-decorum",
"tauri-plugin-dialog",
"tauri-plugin-http",
"tauri-plugin-notification",
"tauri-plugin-opener",
"tauri-plugin-os",
"tauri-plugin-process",
"tauri-plugin-shell",
"tauri-plugin-single-instance",
"tauri-plugin-store",
"tauri-plugin-updater",
"tauri-plugin-window-state",
"tokio",
"uuid",
"webkit2gtk",
"windows 0.61.3",
]
[[package]]
name = "option-ext"
version = "0.2.0"
+3 -3
View File
@@ -1,8 +1,8 @@
[package]
name = "opencode-desktop"
name = "kilo-desktop"
version = "0.0.0"
description = "The open source AI coding agent"
authors = ["Anomaly Innovations"]
authors = ["Kilo"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -11,7 +11,7 @@ edition = "2024"
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "opencode_lib"
name = "kilo_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>ai.opencode.opencode</id>
<id>ai.kilo.kilo</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>MIT</project_license>
<name>OpenCode</name>
<name>Kilo</name>
<summary>Open source AI coding agent</summary>
<developer id="ly.anoma">
@@ -14,21 +14,21 @@
<description>
<p>
OpenCode is an open source agent that helps you write and run code with any AI model.
Kilo is an open source agent that helps you write and run code with any AI model.
</p>
</description>
<launchable type="desktop-id">ai.opencode.opencode.desktop</launchable>
<launchable type="desktop-id">ai.kilo.kilo.desktop</launchable>
<content_rating type="oars-1.1" />
<url type="bugtracker">https://github.com/Kilo-Org/kilo/issues</url>
<url type="homepage">https://opencode.ai</url>
<url type="homepage">https://kilo.ai</url>
<url type="vcs-browser">https://github.com/Kilo-Org/kilo</url>
<screenshots>
<screenshot type="default">
<image>https://opencode.ai/docs/_astro/screenshot.Bs5D4atL_ZvsvFu.webp</image>
<image>https://kilo.ai/docs/_astro/screenshot.Bs5D4atL_ZvsvFu.webp</image>
</screenshot>
</screenshots>
+5 -5
View File
@@ -1,8 +1,8 @@
use tauri::{AppHandle, Manager, path::BaseDirectory};
use tauri_plugin_shell::{ShellExt, process::Command};
const CLI_INSTALL_DIR: &str = ".opencode/bin";
const CLI_BINARY_NAME: &str = "opencode";
const CLI_INSTALL_DIR: &str = ".kilo/bin"; // kilocode_change
const CLI_BINARY_NAME: &str = "kilo"; // kilocode_change
#[derive(serde::Deserialize)]
pub struct ServerConfig {
@@ -39,7 +39,7 @@ pub fn get_sidecar_path(app: &tauri::AppHandle) -> std::path::PathBuf {
.expect("Failed to get current binary")
.parent()
.expect("Failed to get parent dir")
.join("opencode-cli")
.join("kilo-cli") // kilocode_change
}
fn is_cli_installed() -> bool {
@@ -61,7 +61,7 @@ pub fn install_cli(app: tauri::AppHandle) -> Result<String, String> {
return Err("Sidecar binary not found".to_string());
}
let temp_script = std::env::temp_dir().join("opencode-install.sh");
let temp_script = std::env::temp_dir().join("kilo-install.sh"); // kilocode_change
std::fs::write(&temp_script, INSTALL_SCRIPT)
.map_err(|e| format!("Failed to write install script: {}", e))?;
@@ -153,7 +153,7 @@ pub fn create_command(app: &tauri::AppHandle, args: &str) -> Command {
#[cfg(target_os = "windows")]
return app
.shell()
.sidecar("opencode-cli")
.sidecar("kilo-cli")
.unwrap()
.args(args.split_whitespace())
.env("OPENCODE_EXPERIMENTAL_ICON_DISCOVERY", "true")
+2 -2
View File
@@ -25,7 +25,7 @@ use tokio::sync::oneshot;
use crate::window_customizer::PinchZoomDisablePlugin;
const SETTINGS_STORE: &str = "opencode.settings.dat";
const SETTINGS_STORE: &str = "kilo.settings.dat"; // kilocode_change
const DEFAULT_SERVER_URL_KEY: &str = "defaultServerUrl";
#[derive(Clone, serde::Serialize)]
@@ -252,7 +252,7 @@ pub fn run() {
#[cfg(all(target_os = "macos", not(debug_assertions)))]
let _ = std::process::Command::new("killall")
.arg("opencode-cli")
.arg("kilo-cli") // kilocode_change
.output();
let mut builder = tauri::Builder::default()
+1 -1
View File
@@ -61,5 +61,5 @@ fn main() {
}
}
opencode_lib::run()
kilo_lib::run() // kilocode_change
}
+5 -5
View File
@@ -1,8 +1,8 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "OpenCode Dev",
"identifier": "ai.opencode.desktop.dev",
"mainBinaryName": "OpenCode",
"productName": "Kilo Dev",
"identifier": "ai.kilo.desktop.dev",
"mainBinaryName": "Kilo",
"version": "../package.json",
"build": {
"beforeDevCommand": "bun run dev",
@@ -15,7 +15,7 @@
{
"label": "main",
"create": false,
"title": "OpenCode",
"title": "Kilo",
"url": "/",
"decorations": true,
"dragDropEnabled": false,
@@ -41,7 +41,7 @@
],
"active": true,
"targets": ["deb", "rpm", "dmg", "nsis", "app"],
"externalBin": ["sidecars/opencode-cli"],
"externalBin": ["sidecars/kilo-cli"],
"macOS": {
"entitlements": "./entitlements.plist"
},
@@ -1,13 +1,13 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "OpenCode",
"identifier": "ai.opencode.desktop",
"productName": "Kilo",
"identifier": "ai.kilo.desktop",
"app": {
"windows": [
{
"label": "main",
"create": false,
"title": "OpenCode",
"title": "Kilo",
"url": "/",
"decorations": true,
"dragDropEnabled": false,
@@ -40,7 +40,7 @@
"linux": {
"deb": {
"files": {
"/usr/share/metainfo/ai.opencode.opencode.metainfo.xml": "release/appstream.metainfo.xml"
"/usr/share/metainfo/ai.kilo.kilo.metainfo.xml": "release/appstream.metainfo.xml"
}
}
}
+3 -1
View File
@@ -4,9 +4,11 @@ import { message } from "@tauri-apps/plugin-dialog"
export async function installCli(): Promise<void> {
try {
const path = await invoke<string>("install_cli")
await message(`CLI installed to ${path}\n\nRestart your terminal to use the 'opencode' command.`, {
// kilocode_change start
await message(`CLI installed to ${path}\n\nRestart your terminal to use the 'kilo' command.`, {
title: "CLI Installed",
})
// kilocode_change end
} catch (e) {
await message(`Failed to install CLI: ${e}`, { title: "Installation Failed" })
}
+2 -2
View File
@@ -47,7 +47,6 @@
"zod-to-json-schema": "3.24.5"
},
"dependencies": {
"@kilocode/kilo-telemetry": "workspace:*",
"@actions/core": "1.11.1",
"@actions/github": "6.0.1",
"@agentclientprotocol/sdk": "0.12.0",
@@ -75,13 +74,14 @@
"@hono/standard-validator": "0.1.5",
"@hono/zod-validator": "catalog:",
"@kilocode/kilo-gateway": "workspace:*",
"@kilocode/kilo-telemetry": "workspace:*",
"@kilocode/sdk": "workspace:*",
"@modelcontextprotocol/sdk": "1.25.2",
"@octokit/graphql": "9.0.2",
"@octokit/rest": "catalog:",
"@openauthjs/openauth": "catalog:",
"@opencode-ai/plugin": "workspace:*",
"@opencode-ai/script": "workspace:*",
"@kilocode/sdk": "workspace:*",
"@opencode-ai/util": "workspace:*",
"@openrouter/ai-sdk-provider": "1.5.2",
"@opentui/core": "0.1.74",