nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 installShellFiles,
6 age-plugin-fido2-hmac,
7 age-plugin-ledger,
8 age-plugin-se,
9 age-plugin-sss,
10 age-plugin-tpm,
11 age-plugin-yubikey,
12 age-plugin-1p,
13 makeWrapper,
14 runCommand,
15 versionCheckHook,
16 nix-update-script,
17}:
18
19buildGoModule (final: {
20 pname = "age";
21 version = "1.3.1";
22
23 src = fetchFromGitHub {
24 owner = "FiloSottile";
25 repo = "age";
26 tag = "v${final.version}";
27 hash = "sha256-Qs/q3zQYV0PukABBPf/aU5V1oOhw95NG6K301VYJk8A=";
28 };
29
30 vendorHash = "sha256-iVDkYXXR2pXlUVywPgVRNMORxOOEhAmzpSM0xqSQMSQ=";
31
32 ldflags = [
33 "-s"
34 "-w"
35 "-X main.Version=v${final.version}"
36 ];
37
38 nativeBuildInputs = [ installShellFiles ];
39
40 preInstall = ''
41 installManPage doc/*.1
42 '';
43
44 nativeInstallCheckInputs = [ versionCheckHook ];
45 versionCheckProgramArg = "--version";
46 doInstallCheck = true;
47
48 # plugin test is flaky, see https://github.com/FiloSottile/age/issues/517
49 checkFlags = [
50 "-skip"
51 "TestScript/plugin"
52 ];
53
54 # group age plugins together
55 passthru.plugins = {
56 inherit
57 age-plugin-fido2-hmac
58 age-plugin-ledger
59 age-plugin-se
60 age-plugin-sss
61 age-plugin-tpm
62 age-plugin-yubikey
63 age-plugin-1p
64 ;
65 };
66
67 # convenience function for wrapping sops with plugins
68 passthru.withPlugins =
69 filter:
70 runCommand "age-${final.version}-with-plugins" { nativeBuildInputs = [ makeWrapper ]; } ''
71 makeWrapper ${lib.getBin final.finalPackage}/bin/age $out/bin/age \
72 --prefix PATH : "${lib.makeBinPath (filter final.passthru.plugins)}"
73 '';
74
75 passthru.updateScript = nix-update-script { };
76
77 meta = {
78 changelog = "https://github.com/FiloSottile/age/releases/tag/v${final.version}";
79 homepage = "https://age-encryption.org/";
80 description = "Modern encryption tool with small explicit keys";
81 license = lib.licenses.bsd3;
82 mainProgram = "age";
83 maintainers = with lib.maintainers; [ tazjin ];
84 };
85})