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}:
16
17buildGoModule (final: {
18 pname = "age";
19 version = "1.2.1";
20
21 src = fetchFromGitHub {
22 owner = "FiloSottile";
23 repo = "age";
24 tag = "v${final.version}";
25 hash = "sha256-9ZJdrmqBj43zSvStt0r25wjSfnvitdx3GYtM3urHcaA=";
26 };
27
28 vendorHash = "sha256-ilRLEV7qOBZbqzg2XQi4kt0JAb/1ftT4JmahYT0zSRU=";
29
30 ldflags = [
31 "-s"
32 "-w"
33 "-X main.Version=${final.version}"
34 ];
35
36 nativeBuildInputs = [
37 installShellFiles
38 ];
39
40 preInstall = ''
41 installManPage doc/*.1
42 '';
43
44 doInstallCheck = true;
45 installCheckPhase = ''
46 if [[ "$("$out/bin/${final.pname}" --version)" == "${final.version}" ]]; then
47 echo '${final.pname} smoke check passed'
48 else
49 echo '${final.pname} smoke check failed'
50 return 1
51 fi
52 '';
53
54 # plugin test is flaky, see https://github.com/FiloSottile/age/issues/517
55 checkFlags = [
56 "-skip"
57 "TestScript/plugin"
58 ];
59
60 # group age plugins together
61 passthru.plugins = {
62 inherit
63 age-plugin-fido2-hmac
64 age-plugin-ledger
65 age-plugin-se
66 age-plugin-sss
67 age-plugin-tpm
68 age-plugin-yubikey
69 age-plugin-1p
70 ;
71 };
72
73 # convenience function for wrapping sops with plugins
74 passthru.withPlugins =
75 filter:
76 runCommand "age-${final.version}-with-plugins"
77 {
78 nativeBuildInputs = [ makeWrapper ];
79 }
80 ''
81 makeWrapper ${lib.getBin final.finalPackage}/bin/age $out/bin/age \
82 --prefix PATH : "${lib.makeBinPath (filter final.passthru.plugins)}"
83 '';
84
85 meta = with lib; {
86 changelog = "https://github.com/FiloSottile/age/releases/tag/v${final.version}";
87 homepage = "https://age-encryption.org/";
88 description = "Modern encryption tool with small explicit keys";
89 license = licenses.bsd3;
90 mainProgram = "age";
91 maintainers = with maintainers; [ tazjin ];
92 };
93})