Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 84 lines 2.2 kB view raw
1{ 2 lib, 3 stdenv, 4 buildGoModule, 5 installShellFiles, 6 fetchFromGitHub, 7 gitUpdater, 8 testers, 9 mods, 10 installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 11 installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 12}: 13 14buildGoModule (finalAttrs: { 15 pname = "mods"; 16 version = "1.8.1"; 17 18 src = fetchFromGitHub { 19 owner = "charmbracelet"; 20 repo = "mods"; 21 tag = "v${finalAttrs.version}"; 22 hash = "sha256-CT90uMQc0quQK/vCeLiHH8taEkCSDIcO7Q3aA+oaNmY="; 23 }; 24 25 # Otherwise checks fail with `panic: open /etc/protocols: operation not permitted` when sandboxing is enabled on Darwin 26 # https://github.com/NixOS/nixpkgs/pull/381645#issuecomment-2656211797 27 modPostBuild = '' 28 substituteInPlace vendor/modernc.org/libc/honnef.co/go/netdb/netdb.go \ 29 --replace-quiet '!os.IsNotExist(err)' '!os.IsNotExist(err) && !os.IsPermission(err)' 30 ''; 31 32 vendorHash = "sha256-jtSuSKy6GpWrJAXVN2Acmtj8klIQrgJjNwgyRZIyqyY="; 33 34 nativeBuildInputs = lib.optionals (installManPages || installShellCompletions) [ 35 installShellFiles 36 ]; 37 38 ldflags = [ 39 "-s" 40 "-w" 41 "-X=main.Version=${finalAttrs.version}" 42 ]; 43 44 # These tests require internet access. 45 checkFlags = [ "-skip=^TestLoad/http_url$|^TestLoad/https_url$" ]; 46 47 passthru = { 48 updateScript = gitUpdater { 49 rev-prefix = "v"; 50 ignoredVersions = ".(rc|beta).*"; 51 }; 52 53 tests.version = testers.testVersion { 54 package = mods; 55 command = "HOME=$(mktemp -d) mods -v"; 56 }; 57 }; 58 59 postInstall = '' 60 export HOME=$(mktemp -d) 61 '' 62 + lib.optionalString installManPages '' 63 $out/bin/mods man > ./mods.1 64 installManPage ./mods.1 65 '' 66 + lib.optionalString installShellCompletions '' 67 installShellCompletion --cmd mods \ 68 --bash <($out/bin/mods completion bash) \ 69 --fish <($out/bin/mods completion fish) \ 70 --zsh <($out/bin/mods completion zsh) 71 ''; 72 73 meta = { 74 description = "AI on the command line"; 75 homepage = "https://github.com/charmbracelet/mods"; 76 license = lib.licenses.mit; 77 maintainers = with lib.maintainers; [ 78 dit7ya 79 caarlos0 80 delafthi 81 ]; 82 mainProgram = "mods"; 83 }; 84})