Skip to content

Commit 681758a

Browse files
NovaViperbrianmcgee
andcommitted
feat: add age plugin and fido2 hmac support
Co-authored-by: brianmcgee <brian@41north.dev>
1 parent 5e3e92b commit 681758a

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
;
6262
# backward compatibility
6363
inherit (prev) ssh-to-pgp;
64+
65+
sops = prev.sops.withAgePlugins (p: [
66+
p.age-plugin-fido2-hmac
67+
]);
6468
};
6569
nixosModules = {
6670
sops = ./modules/sops;

modules/home-manager/sops.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ in
240240
'';
241241
};
242242

243+
plugins = lib.mkOption {
244+
type = lib.types.listOf lib.types.package;
245+
default = [
246+
pkgs.age-plugin-fido2-hmac
247+
];
248+
description = ''
249+
List of plugins to use for sops decryption.
250+
'';
251+
};
252+
243253
generateKey = lib.mkOption {
244254
type = lib.types.bool;
245255
default = false;
@@ -339,6 +349,8 @@ in
339349
))
340350
];
341351

352+
PATH = lib.makeBinPath cfg.age.plugins;
353+
342354
QUBES_GPG_DOMAIN = lib.mkIf cfg.gnupg.qubes-split-gpg.enable (
343355
lib.mkDefault cfg.gnupg.qubes-split-gpg.domain
344356
);

modules/sops/default.nix

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,16 @@ in
329329
'';
330330
};
331331

332+
plugins = lib.mkOption {
333+
type = lib.types.listOf lib.types.package;
334+
default = [
335+
pkgs.age-plugin-fido2-hmac
336+
];
337+
description = ''
338+
List of plugins to use for sops decryption.
339+
'';
340+
};
341+
332342
generateKey = lib.mkOption {
333343
type = lib.types.bool;
334344
default = false;
@@ -432,12 +442,15 @@ in
432442
lib.mkDefault "${pkgs.gnupg}/bin/gpg"
433443
);
434444

445+
sops.environment.PATH = lib.makeBinPath cfg.age.plugins;
446+
435447
# When using sysusers we no longer are started as an activation script because those are started in initrd while sysusers is started later.
436448
systemd.services.sops-install-secrets = lib.mkIf (regularSecrets != { } && useSystemdActivation) {
437449
wantedBy = [ "sysinit.target" ];
438450
after = [ "systemd-sysusers.service" ];
439-
environment = cfg.environment;
451+
environment = cfg.environment // {PATH = lib.mkForce "${cfg.environment.PATH}:${lib.makeSearchPathOutput "bin" "sbin" cfg.age.plugins}";};
440452
unitConfig.DefaultDependencies = "no";
453+
path = config.sops.age.plugins;
441454

442455
serviceConfig = {
443456
Type = "oneshot";

modules/sops/secrets-for-users/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ in
3434
{
3535
wantedBy = [ "systemd-sysusers.service" ];
3636
before = [ "systemd-sysusers.service" ];
37-
environment = cfg.environment;
37+
environment = cfg.environment // {PATH = lib.mkForce "${cfg.environment.PATH}:${lib.makeSearchPathOutput "bin" "sbin" cfg.age.plugins}";};
3838
unitConfig.DefaultDependencies = "no";
39+
path = config.sops.age.plugins;
3940

4041
serviceConfig = {
4142
Type = "oneshot";

0 commit comments

Comments
 (0)