[NixOS] Set up agenix and auto import gpg key
This commit is contained in:
21
nixos/secrets.nix
Normal file
21
nixos/secrets.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{ inputs, pkgs, ... }: {
|
||||
home-manager.users.imalison = ({ config, ... }: {
|
||||
imports = [ inputs.agenix.homeManagerModules.default ];
|
||||
age.identityPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ];
|
||||
home.packages = [
|
||||
inputs.agenix.packages."${pkgs.system}".default
|
||||
];
|
||||
age.secrets.gpg-keys.file = ./secrets/gpg-keys.age;
|
||||
|
||||
systemd.user.services.import-gpg-key = {
|
||||
Unit = {
|
||||
Description = "Import GPG private key";
|
||||
};
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.gnupg}/bin/gpg --batch --import /run/user/%U/agenix/gpg-keys";
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user