|
4 | 4 | inputs = { |
5 | 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
6 | 6 | 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; }; |
7 | 15 | }; |
8 | 16 |
|
9 | | - outputs = { self, nixpkgs, flake-utils }: |
| 17 | + outputs = { self, nixpkgs, flake-utils, eyrie, inspect, sight, tok, trace, yaad }: |
10 | 18 | flake-utils.lib.eachDefaultSystem (system: |
11 | 19 | let |
12 | 20 | 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 | + |
14 | 55 | hawk = pkgs.buildGoModule rec { |
15 | 56 | pname = "hawk"; |
16 | 57 | version = "0.1.0"; |
17 | | - |
| 58 | + |
18 | 59 | 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. |
20 | 67 | 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 | + |
22 | 83 | ldflags = [ |
23 | 84 | "-s" |
24 | 85 | "-w" |
25 | 86 | "-X main.Version=${version}" |
26 | 87 | ]; |
27 | | - |
| 88 | + |
28 | 89 | nativeBuildInputs = [ pkgs.git ]; |
29 | | - |
30 | | - meta = with pkgs.lib; { |
| 90 | + |
| 91 | + meta = with lib; { |
31 | 92 | description = "AI coding agent that reads, writes, and runs code in your terminal"; |
32 | 93 | homepage = "https://github.com/GrayCodeAI/hawk"; |
33 | 94 | license = licenses.mit; |
|
38 | 99 | { |
39 | 100 | packages = { |
40 | 101 | default = hawk; |
41 | | - hawk = hawk; |
| 102 | + inherit hawk; |
42 | 103 | }; |
43 | 104 |
|
44 | 105 | devShells.default = pkgs.mkShell { |
|
0 commit comments