Skip to content

Commit cdb218d

Browse files
CopilotMic92
andcommitted
crush: use FOD to vendor and patch catwalk dependency
Implement FOD approach to pre-fetch catwalk, patch its go.mod to relax version constraints, and use a replace directive in the main go.mod. This successfully bypasses the [email protected] version check but reveals that catwalk's transitive dependency github.com/charmbracelet/x/[email protected] also requires Go >= 1.25.5. Further patching of additional dependencies would be needed for a complete solution. Co-authored-by: Mic92 <[email protected]>
1 parent 385d392 commit cdb218d

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

packages/crush/package.nix

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,28 @@
44
fetchFromGitHub,
55
installShellFiles,
66
runCommand,
7+
fetchzip,
78
}:
89

910
let
1011
versionData = builtins.fromJSON (builtins.readFile ./hashes.json);
1112
inherit (versionData) version hash vendorHash;
1213

14+
# Pre-fetch and patch catwalk to remove Go version constraint
15+
# This is an FOD that vendors catwalk with a relaxed version requirement
16+
patchedCatwalk = runCommand "catwalk-v0.10.1-patched" {} ''
17+
cp -r ${fetchzip {
18+
url = "https://github.com/charmbracelet/catwalk/archive/refs/tags/v0.10.1.tar.gz";
19+
hash = "sha256-zcWKXojirBEoCUX8YS4JaCXyqn0jRD9uZsoLu//9358=";
20+
}} $out
21+
chmod -R +w $out
22+
23+
# Patch catwalk's go.mod to relax version constraint
24+
sed -i -E 's/^go ([0-9]+\.[0-9]+)\.[0-9]+$/go \1/' $out/go.mod
25+
'';
26+
1327
# Fetch the source and patch go.mod to remove patch-level version constraints
14-
# This addresses the issue where dependencies require Go 1.25.5 but nixpkgs has 1.25.4
15-
# By relaxing the constraint to the minor version (1.25), the build can proceed
28+
# Also add a replace directive to use our patched catwalk
1629
patchedSrc = runCommand "crush-${version}-src" {} ''
1730
cp -r ${fetchFromGitHub {
1831
owner = "charmbracelet";
@@ -23,8 +36,11 @@ let
2336
chmod -R +w $out
2437
2538
# Patch go.mod to relax patch-level version constraints
26-
# Converts "go X.Y.Z" to "go X.Y" to allow building with any patch version
2739
sed -i -E 's/^go ([0-9]+\.[0-9]+)\.[0-9]+$/go \1/' $out/go.mod
40+
41+
# Add replace directive to use our patched catwalk
42+
echo "" >> $out/go.mod
43+
echo "replace github.com/charmbracelet/catwalk => ${patchedCatwalk}" >> $out/go.mod
2844
'';
2945
in
3046
buildGoModule {

0 commit comments

Comments
 (0)