diff --git a/pkgs/by-name/cr/crush/package.nix b/pkgs/by-name/cr/crush/package.nix new file mode 100644 index 000000000000..816a2b4b183f --- /dev/null +++ b/pkgs/by-name/cr/crush/package.nix @@ -0,0 +1,58 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + nix-update-script, + writableTmpDirAsHomeHook, + versionCheckHook, +}: + +buildGoModule (finalAttrs: { + pname = "crush"; + version = "0.2.1"; + + src = fetchFromGitHub { + owner = "charmbracelet"; + repo = "crush"; + tag = "v${finalAttrs.version}"; + hash = "sha256-SjrkQFSjJrPNynARE92uKA53hkstIUBSvQbqcYSsnaM="; + }; + + vendorHash = "sha256-aI3MSaQYUOLJxBxwCoVg13HpxK46q6ZITrw1osx5tiE="; + + ldflags = [ + "-s" + "-w" + "-X=github.com/charmbracelet/crush/internal/version.Version=${finalAttrs.version}" + ]; + + # rename TestMain to prevent it from running, as it panics in the sandbox. + postPatch = '' + sed -i 's/func TestMain/func DisabledTestMain/' internal/llm/provider/openai_test.go + ''; + + checkFlags = + let + # these tests fail in the sandbox + skippedTests = [ + "TestOpenAIClientStreamChoices" + "TestGrepWithIgnoreFiles" + "TestSearchImplementations" + ]; + in + [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ]; + + doInstallCheck = true; + nativeCheckInputs = [ writableTmpDirAsHomeHook ]; + nativeInstallCheckInputs = [ versionCheckHook ]; + + updateScript = nix-update-script { }; + + meta = { + description = "Glamourous AI coding agent for your favourite terminal"; + homepage = "https://github.com/charmbracelet/crush"; + license = lib.licenses.fsl11Mit; + maintainers = with lib.maintainers; [ x123 ]; + mainProgram = "crush"; + }; +})