[NixOS] Provide passphrase when importing gpg key

This commit is contained in:
2023-08-22 19:14:08 -06:00
parent 8faca502c7
commit 3c1619c598
3 changed files with 48 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
inputs.agenix.packages."${pkgs.system}".default
];
age.secrets.gpg-keys.file = ./secrets/gpg-keys.age;
age.secrets.gpg-passphrase.file = ./secrets/gpg-passphrase.age;
systemd.user.services.import-gpg-key = {
Unit = {
@@ -23,7 +24,8 @@
Restart = "onfailure";
ExecStart =
let path = config.age.secrets.gpg-keys.path;
in "${pkgs.gnupg}/bin/gpg --batch --import ${path}";
passphrasePath = config.age.secrets.gpg-passphrase.path;
in "${pkgs.gnupg}/bin/gpg --pinentry-mode loopback --passphrase-file ${passphrasePath} --import ${path}";
};
};
});