1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 asciidoctor,
7 installShellFiles,
8 git,
9 versionCheckHook,
10 nix-update-script,
11}:
12
13buildGoModule rec {
14 pname = "git-lfs";
15 version = "3.6.1";
16
17 src = fetchFromGitHub {
18 owner = "git-lfs";
19 repo = "git-lfs";
20 tag = "v${version}";
21 hash = "sha256-zZ9VYWVV+8G3gojj1m74syvsYM1mX0YT4hKnpkdMAQk=";
22 };
23
24 vendorHash = "sha256-JT0r/hs7ZRtsYh4aXy+v8BjwiLvRJ10e4yRirqmWVW0=";
25
26 nativeBuildInputs = [
27 asciidoctor
28 installShellFiles
29 ];
30
31 ldflags = [
32 "-s"
33 "-w"
34 "-X github.com/git-lfs/git-lfs/v${lib.versions.major version}/config.Vendor=${version}"
35 ];
36
37 subPackages = [ "." ];
38
39 preBuild = ''
40 GOARCH= go generate ./commands
41 '';
42
43 postBuild = ''
44 make man
45 '';
46
47 nativeCheckInputs = [ git ];
48
49 preCheck = ''
50 unset subPackages
51 '';
52
53 checkFlags = lib.optionals stdenv.hostPlatform.isDarwin (
54 let
55 # Fail in the sandbox with network-related errors.
56 # Enabling __darwinAllowLocalNetworking is not enough.
57 skippedTests = [
58 "TestAPIBatch"
59 "TestAPIBatchOnlyBasic"
60 "TestAuthErrWithBody"
61 "TestAuthErrWithoutBody"
62 "TestCertFromSSLCAInfoConfig"
63 "TestCertFromSSLCAInfoEnv"
64 "TestCertFromSSLCAInfoEnvWithSchannelBackend"
65 "TestCertFromSSLCAPathConfig"
66 "TestCertFromSSLCAPathEnv"
67 "TestClientRedirect"
68 "TestClientRedirectReauthenticate"
69 "TestDoAPIRequestWithAuth"
70 "TestDoWithAuthApprove"
71 "TestDoWithAuthNoRetry"
72 "TestDoWithAuthReject"
73 "TestFatalWithBody"
74 "TestFatalWithoutBody"
75 "TestHttp2"
76 "TestHttpVersion"
77 "TestWithNonFatal500WithBody"
78 "TestWithNonFatal500WithoutBody"
79 ];
80 in
81 [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ]
82 );
83
84 postInstall = ''
85 installManPage man/man*/*
86 ''
87 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
88 installShellCompletion --cmd git-lfs \
89 --bash <($out/bin/git-lfs completion bash) \
90 --fish <($out/bin/git-lfs completion fish) \
91 --zsh <($out/bin/git-lfs completion zsh)
92 '';
93
94 nativeInstallCheckInputs = [
95 versionCheckHook
96 ];
97 versionCheckProgramArg = "--version";
98 doInstallCheck = true;
99
100 passthru = {
101 updateScript = nix-update-script { };
102 };
103
104 __darwinAllowLocalNetworking = true;
105
106 meta = {
107 description = "Git extension for versioning large files";
108 homepage = "https://git-lfs.github.com/";
109 changelog = "https://github.com/git-lfs/git-lfs/raw/v${version}/CHANGELOG.md";
110 license = lib.licenses.mit;
111 maintainers = with lib.maintainers; [ twey ];
112 mainProgram = "git-lfs";
113 };
114}