Skip to content

Commit 13a9773

Browse files
authored
refactor: remove legacy API server and localize Nix sibling deps (#61)
* refactor: remove legacy API server and localize nix sibling deps Drop the unused internal API server wiring, update the changelog to match the current daemon surface, and make Nix builds resolve sibling modules locally. * fix: make nix sibling replace setup idempotent Strip any existing sibling replace directives before appending them so the preBuild logic can run multiple times without duplicating go.mod entries.
1 parent c3aaf6b commit 13a9773

5 files changed

Lines changed: 72 additions & 487 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Changed
11-
- **Version re-baselined to `0.1.0`** across `main.go`, `api/server.go`, `flake.nix`,
12-
`.github/workflows/release.yml`, and the `update`/`api` test suites, aligning hawk
11+
- **Version re-baselined to `0.1.0`** across `cmd/hawk/main.go`, `cmd/daemon.go`,
12+
`flake.nix`, `.github/workflows/release.yml`, and the `update`/daemon test suites, aligning hawk
1313
with the rest of the GrayCodeAI ecosystem (`eyrie`, `tok`, `yaad`, `sight`, `inspect`).
1414

1515
### Added

cmd/hawk/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77

88
"github.com/GrayCodeAI/hawk/cmd"
9-
"github.com/GrayCodeAI/hawk/internal/api"
109
"github.com/GrayCodeAI/hawk/internal/hawkerr"
1110
"github.com/GrayCodeAI/hawk/internal/mcp"
1211
"github.com/GrayCodeAI/hawk/internal/sandbox"
@@ -37,7 +36,6 @@ func main() {
3736
// to avoid an import cycle with main.
3837
cmd.SetVersion(Version)
3938
cmd.SetBuildDate(BuildDate)
40-
api.SetVersion(Version)
4139
mcp.SetClientVersion(Version)
4240
sandbox.ContainerImageTag = Version
4341

flake.nix

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,91 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
7+
# GrayCodeAI sibling repos — the public Go proxy has stale v0.1.0 tags
8+
# (post-history-rewrite), so resolve them locally like the Dockerfile.
9+
eyrie = { url = "github:GrayCodeAI/eyrie"; flake = false; };
10+
inspect = { url = "github:GrayCodeAI/inspect"; flake = false; };
11+
sight = { url = "github:GrayCodeAI/sight"; flake = false; };
12+
tok = { url = "github:GrayCodeAI/tok"; flake = false; };
13+
trace = { url = "github:GrayCodeAI/trace"; flake = false; };
14+
yaad = { url = "github:GrayCodeAI/yaad"; flake = false; };
715
};
816

9-
outputs = { self, nixpkgs, flake-utils }:
17+
outputs = { self, nixpkgs, flake-utils, eyrie, inspect, sight, tok, trace, yaad }:
1018
flake-utils.lib.eachDefaultSystem (system:
1119
let
1220
pkgs = nixpkgs.legacyPackages.${system};
13-
21+
inherit (pkgs) lib;
22+
23+
siblings = {
24+
"github.com/GrayCodeAI/eyrie" = eyrie;
25+
"github.com/GrayCodeAI/inspect" = inspect;
26+
"github.com/GrayCodeAI/sight" = sight;
27+
"github.com/GrayCodeAI/tok" = tok;
28+
"github.com/GrayCodeAI/trace" = trace;
29+
"github.com/GrayCodeAI/yaad" = yaad;
30+
};
31+
32+
# GrayCode modules currently follow github.com/<org>/<name>, so the
33+
# last path segment matches the sibling checkout directory name.
34+
dirOf = mod: lib.last (lib.splitString "/" mod);
35+
goVer = lib.removePrefix "go" "${pkgs.go_1_26.version}";
36+
37+
# Copy sibling sources into external/, patch the go.mod go directive
38+
# to match the nixpkgs Go version, and add replace directives so the
39+
# build resolves siblings locally instead of hitting the stale proxy.
40+
setupReplace = ''
41+
sed -i 's/^go [0-9.]\+/go ${goVer}/' go.mod
42+
rm -f go.work go.work.sum
43+
mkdir -p external
44+
${lib.concatStringsSep "\n" (lib.mapAttrsToList (mod: src:
45+
"cp -r ${src} external/${dirOf mod}"
46+
) siblings)}
47+
${lib.concatStringsSep "\n" (lib.mapAttrsToList (mod: _:
48+
"tmp_go_mod=$(mktemp) && awk '$0 != \"replace ${mod} => ./external/${dirOf mod}\"' go.mod > \"$tmp_go_mod\" && mv \"$tmp_go_mod\" go.mod"
49+
) siblings)}
50+
${lib.concatStringsSep "\n" (lib.mapAttrsToList (mod: _:
51+
"echo \"replace ${mod} => ./external/${dirOf mod}\" >> go.mod"
52+
) siblings)}
53+
'';
54+
1455
hawk = pkgs.buildGoModule rec {
1556
pname = "hawk";
1657
version = "0.1.0";
17-
58+
1859
src = ./.;
19-
60+
61+
# The public Go proxy has stale v0.1.0 tags for GrayCodeAI sibling
62+
# modules (post-history-rewrite). We resolve siblings locally via
63+
# replace directives in go.mod (added in preBuild below). External
64+
# deps (charmbracelet, cobra, …) are fetched from the proxy. The
65+
# vendor FOD is skipped (null) because the proxy version mismatch
66+
# prevents `go mod vendor` from passing checksum verification.
2067
vendorHash = null;
21-
68+
69+
env = {
70+
GOPRIVATE = "github.com/GrayCodeAI/*";
71+
GONOSUMDB = "github.com/GrayCodeAI/*";
72+
GONOSUMCHECK = "1";
73+
GOFLAGS = "-mod=mod";
74+
};
75+
76+
# Add replace directives to go.mod so the build and vendor FOD
77+
# resolve sibling modules locally instead of from the stale proxy.
78+
preBuild = setupReplace;
79+
overrideModAttrs = old: {
80+
preBuild = setupReplace;
81+
};
82+
2283
ldflags = [
2384
"-s"
2485
"-w"
2586
"-X main.Version=${version}"
2687
];
27-
88+
2889
nativeBuildInputs = [ pkgs.git ];
29-
30-
meta = with pkgs.lib; {
90+
91+
meta = with lib; {
3192
description = "AI coding agent that reads, writes, and runs code in your terminal";
3293
homepage = "https://github.com/GrayCodeAI/hawk";
3394
license = licenses.mit;
@@ -38,7 +99,7 @@
3899
{
39100
packages = {
40101
default = hawk;
41-
hawk = hawk;
102+
inherit hawk;
42103
};
43104

44105
devShells.default = pkgs.mkShell {

internal/api/server.go

Lines changed: 0 additions & 253 deletions
This file was deleted.

0 commit comments

Comments
 (0)