nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7}:
8
9buildGoModule rec {
10 pname = "driftctl";
11 version = "0.40.0";
12
13 src = fetchFromGitHub {
14 owner = "snyk";
15 repo = "driftctl";
16 rev = "v${version}";
17 sha256 = "sha256-IDKfW0NCEsgKXpHA7SwkHjMeoGAIYITlDVR/vI/b9hk=";
18 };
19
20 vendorHash = "sha256-JFvC9PReziktHSXbltGkGHjVR8hTM1hPJ0OqrZQXRQM=";
21
22 nativeBuildInputs = [ installShellFiles ];
23
24 ldflags = [
25 "-s"
26 "-w"
27 "-X github.com/snyk/driftctl/pkg/version.version=v${version}"
28 "-X github.com/snyk/driftctl/build.env=release"
29 "-X github.com/snyk/driftctl/build.enableUsageReporting=false"
30 ];
31
32 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
33 installShellCompletion --cmd driftctl \
34 --bash <($out/bin/driftctl completion bash) \
35 --fish <($out/bin/driftctl completion fish) \
36 --zsh <($out/bin/driftctl completion zsh)
37 '';
38
39 doInstallCheck = true;
40 installCheckPhase = ''
41 runHook preInstallCheck
42
43 $out/bin/driftctl --help
44 $out/bin/driftctl version | grep "v${version}"
45 # check there's no telemetry flag
46 $out/bin/driftctl --help | grep -vz "telemetry"
47
48 runHook postInstallCheck
49 '';
50
51 meta = {
52 homepage = "https://driftctl.com/";
53 changelog = "https://github.com/snyk/driftctl/releases/tag/v${version}";
54 description = "Detect, track and alert on infrastructure drift";
55 mainProgram = "driftctl";
56 longDescription = ''
57 driftctl is a free and open-source CLI that warns of infrastructure drift
58 and fills in the missing piece in your DevSecOps toolbox.
59 '';
60 license = lib.licenses.asl20;
61 maintainers = with lib.maintainers; [
62 kaction
63 jk
64 qjoly
65 ];
66 };
67}