1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 installShellFiles,
6 versionCheckHook,
7 nix-update-script,
8 makeWrapper,
9 runCommand,
10 age,
11}:
12
13buildGoModule (final: {
14 pname = "sops";
15 version = "3.10.2";
16
17 src = fetchFromGitHub {
18 owner = "getsops";
19 repo = final.pname;
20 tag = "v${final.version}";
21 hash = "sha256-IdQnxVBMAQpSAYB2S3D3lSULelFMBpjiBGOxeTgC10I=";
22 };
23
24 vendorHash = "sha256-7aHUIERVSxv3YGAMteGbqkAZQXXDVziV0rhUhjwch3U=";
25
26 subPackages = [ "cmd/sops" ];
27
28 ldflags = [
29 "-s"
30 "-w"
31 "-X github.com/getsops/sops/v3/version.Version=${final.version}"
32 ];
33
34 nativeBuildInputs = [
35 installShellFiles
36 makeWrapper
37 ];
38
39 postInstall = ''
40 installShellCompletion --cmd sops --bash ${./bash_autocomplete}
41 installShellCompletion --cmd sops --zsh ${./zsh_autocomplete}
42 '';
43
44 nativeInstallCheckInputs = [ versionCheckHook ];
45 versionCheckProgramArg = "--version";
46 doInstallCheck = true;
47
48 passthru.updateScript = nix-update-script { };
49
50 # wrap sops with age plugins
51 passthru.withAgePlugins =
52 filter:
53 runCommand "sops-${final.version}-with-age-plugins"
54 {
55 nativeBuildInputs = [ makeWrapper ];
56 }
57 ''
58 makeWrapper ${lib.getBin final.finalPackage}/bin/sops $out/bin/sops \
59 --prefix PATH : "${lib.makeBinPath (filter age.passthru.plugins)}"
60 '';
61
62 meta = {
63 homepage = "https://getsops.io/";
64 description = "Simple and flexible tool for managing secrets";
65 changelog = "https://github.com/getsops/sops/blob/v${final.version}/CHANGELOG.rst";
66 mainProgram = "sops";
67 maintainers = with lib.maintainers; [
68 Scrumplex
69 mic92
70 ];
71 license = lib.licenses.mpl20;
72 };
73})