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