Skip to content

Commit faef2bd

Browse files
committed
feat: add age plugin and fido2 hmac support
1 parent 53c853f commit faef2bd

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

default.nix

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ rec {
1414

1515
sops-import-keys-hook = pkgs.callPackage ./pkgs/sops-import-keys-hook { };
1616

17+
age-fido2-hmac = pkgs.callPackage ./pkgs/age-fido2-hmac {};
18+
sops-fido2-hmac = pkgs.callPackage ./pkgs/sops-fido2-hmac {};
19+
1720
# backwards compatibility
1821
inherit (pkgs) ssh-to-pgp;
1922

modules/sops/default.nix

+9
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ in
319319
'';
320320
};
321321

322+
plugins = lib.mkOption {
323+
type = lib.types.listOf lib.types.package;
324+
default = [];
325+
description = ''
326+
List of plugins to use for sops decryption.
327+
'';
328+
};
329+
322330
generateKey = lib.mkOption {
323331
type = lib.types.bool;
324332
default = false;
@@ -431,6 +439,7 @@ in
431439
sops.environment.SOPS_GPG_EXEC = lib.mkIf (cfg.gnupg.home != null || cfg.gnupg.sshKeyPaths != [ ]) (
432440
lib.mkDefault "${pkgs.gnupg}/bin/gpg"
433441
);
442+
sops.environment.PATH= lib.makeBinPath cfg.age.plugins;
434443

435444
# When using sysusers we no longer are started as an activation script because those are started in initrd while sysusers is started later.
436445
systemd.services.sops-install-secrets = lib.mkIf (regularSecrets != { } && useSystemdActivation) {

pkgs/age-fido2-hmac/default.nix

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ age-plugin-fido2-hmac
2+
, runCommand
3+
, makeWrapper
4+
, lib
5+
, age
6+
}:
7+
8+
runCommand "age" {
9+
nativeBuildInputs = [ makeWrapper ];
10+
} ''
11+
mkdir -p $out/bin
12+
makeWrapper ${age}/bin/age $out/bin/age \
13+
--prefix PATH : ${lib.makeBinPath [ age-plugin-fido2-hmac ]}
14+
''

pkgs/sops-fido2-hmac/default.nix

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
sops,
3+
fetchFromGitHub,
4+
buildGoModule,
5+
age-plugin-fido2-hmac,
6+
makeWrapper
7+
}:
8+
9+
let
10+
version = "2024-11-23";
11+
in
12+
buildGoModule {
13+
pname = "sops-fido2-hmac";
14+
inherit version;
15+
src = fetchFromGitHub {
16+
owner = "brianmcgee";
17+
repo = "sops";
18+
rev = "0607eae847f1ae21205b5e2a919de6d5868f6395";
19+
sha256 = "sha256-mWsIg9TXGlA8EuFD7Pb0w8PsD3LvCMCy1X9OTITxvsU=";
20+
};
21+
vendorHash = "sha256-NS0b25NQEJle///iRHAG3uTC5p6rlGSyHVwEESki3p4=";
22+
23+
subPackages = [ "cmd/sops" ];
24+
25+
ldflags = [
26+
"-s"
27+
"-w"
28+
"-X github.com/getsops/sops/v3/version.Version=${version}"
29+
];
30+
31+
nativeBuildInputs = [ makeWrapper ];
32+
33+
postInstall = ''
34+
wrapProgram $out/bin/sops --prefix PATH : ${age-plugin-fido2-hmac}/bin
35+
'';
36+
37+
inherit (sops) meta;
38+
}

0 commit comments

Comments
 (0)