mods: general improvements to the mods package (#425744)

authored by Aleksana and committed by GitHub 86e396ed 3b9a9692

+23 -15
+23 -15
pkgs/by-name/mo/mods/package.nix
··· 1 1 { 2 2 lib, 3 + stdenv, 3 4 buildGoModule, 4 5 installShellFiles, 5 6 fetchFromGitHub, 6 7 gitUpdater, 7 8 testers, 8 9 mods, 10 + installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 11 + installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 9 12 }: 10 13 11 - buildGoModule rec { 14 + buildGoModule (finalAttrs: { 12 15 pname = "mods"; 13 16 version = "1.7.0"; 14 17 15 18 src = fetchFromGitHub { 16 19 owner = "charmbracelet"; 17 20 repo = "mods"; 18 - rev = "v${version}"; 21 + tag = "v${finalAttrs.version}"; 19 22 hash = "sha256-wzLYkcgUWPzghJEhYRh7HH19Rqov1RJAxdgp3AGnOTY="; 20 23 }; 21 24 22 25 vendorHash = "sha256-L+4vkh7u6uMm5ICMk8ke5RVY1oYeKMYWVYYq9YqpKiw="; 23 26 24 - nativeBuildInputs = [ 27 + nativeBuildInputs = lib.optionals (installManPages || installShellCompletions) [ 25 28 installShellFiles 26 29 ]; 27 30 28 31 ldflags = [ 29 32 "-s" 30 33 "-w" 31 - "-X=main.Version=${version}" 34 + "-X=main.Version=${finalAttrs.version}" 32 35 ]; 33 36 34 37 # These tests require internet access. ··· 46 49 }; 47 50 }; 48 51 49 - postInstall = '' 50 - export HOME=$(mktemp -d) 51 - $out/bin/mods man > mods.1 52 - $out/bin/mods completion bash > mods.bash 53 - $out/bin/mods completion fish > mods.fish 54 - $out/bin/mods completion zsh > mods.zsh 55 - 56 - installManPage mods.1 57 - installShellCompletion mods.{bash,fish,zsh} 58 - ''; 52 + postInstall = 53 + '' 54 + export HOME=$(mktemp -d) 55 + '' 56 + + lib.optionalString installManPages '' 57 + $out/bin/mods man > ./mods.1 58 + installManPage ./mods.1 59 + '' 60 + + lib.optionalString installShellCompletions '' 61 + installShellCompletion --cmd mods \ 62 + --bash <($out/bin/mods completion bash) \ 63 + --fish <($out/bin/mods completion fish) \ 64 + --zsh <($out/bin/mods completion zsh) 65 + ''; 59 66 60 67 meta = { 61 68 description = "AI on the command line"; ··· 64 71 maintainers = with lib.maintainers; [ 65 72 dit7ya 66 73 caarlos0 74 + delafthi 67 75 ]; 68 76 mainProgram = "mods"; 69 77 }; 70 - } 78 + })