acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / we / werf / package.nix
blob8eaeedf58c1ca27127502e0418522b3dd0b07b65
2   lib,
3   stdenv,
4   buildGoModule,
5   fetchFromGitHub,
6   installShellFiles,
7   btrfs-progs,
8   testers,
9   werf,
12 buildGoModule rec {
13   pname = "werf";
14   version = "2.12.1";
16   src = fetchFromGitHub {
17     owner = "werf";
18     repo = "werf";
19     rev = "v${version}";
20     hash = "sha256-EVFNUOvczsgU0t2hOfl4e5bFH4ByxmRsIk2idI+uquQ=";
21   };
23   vendorHash = "sha256-eJT3ROX/cAslWMNUdlFU6eQE8o2GlAFKrBaT//Pde1o=";
25   proxyVendor = true;
27   subPackages = [ "cmd/werf" ];
29   nativeBuildInputs = [ installShellFiles ];
31   buildInputs =
32     lib.optionals stdenv.hostPlatform.isLinux [ btrfs-progs ]
33     ++ lib.optionals stdenv.hostPlatform.isGnu [ stdenv.cc.libc.static ];
35   CGO_ENABLED = if stdenv.hostPlatform.isLinux then 1 else 0;
37   ldflags =
38     [
39       "-s"
40       "-w"
41       "-X github.com/werf/werf/v2/pkg/werf.Version=v${version}"
42     ]
43     ++ lib.optionals (CGO_ENABLED == 1) [
44       "-extldflags=-static"
45       "-linkmode external"
46     ];
48   tags =
49     [
50       "containers_image_openpgp"
51       "dfrunmount"
52       "dfrunnetwork"
53       "dfrunsecurity"
54       "dfssh"
55     ]
56     ++ lib.optionals (CGO_ENABLED == 1) [
57       "cni"
58       "exclude_graphdriver_devicemapper"
59       "netgo"
60       "no_devmapper"
61       "osusergo"
62       "static_build"
63     ];
65   preCheck =
66     ''
67       # Test all targets.
68       unset subPackages
70       # Remove tests that require external services.
71       rm -rf \
72         integration/suites \
73         pkg/true_git/*test.go \
74         test/e2e
75     ''
76     + lib.optionalString (CGO_ENABLED == 0) ''
77       # A workaround for osusergo.
78       export USER=nixbld
79     '';
81   postInstall = ''
82     installShellCompletion --cmd werf \
83       --bash <($out/bin/werf completion --shell=bash) \
84       --zsh <($out/bin/werf completion --shell=zsh)
85   '';
87   passthru.tests.version = testers.testVersion {
88     package = werf;
89     command = "werf version";
90     version = src.rev;
91   };
93   meta = with lib; {
94     description = "GitOps delivery tool";
95     mainProgram = "werf";
96     longDescription = ''
97       The CLI tool gluing Git, Docker, Helm & Kubernetes with any CI system to
98       implement CI/CD and Giterminism.
99     '';
100     homepage = "https://werf.io";
101     changelog = "https://github.com/werf/werf/releases/tag/${src.rev}";
102     license = licenses.asl20;
103     maintainers = with maintainers; [ azahi ];
104   };