aboutsummaryrefslogtreecommitdiffstats
path: root/modules/security/gpg/default.nix
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 02:02:23 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 03:50:32 +0530
commit41bdeb88009dd232808edee9fc0e4ae94358d8d6 (patch)
treec1a41f54e086064dac178ebed24d36ab34087c32 /modules/security/gpg/default.nix
parent530299d97926d45939f831dc3ea5e444d2839d08 (diff)
downloadhome-manager-config-41bdeb88009dd232808edee9fc0e4ae94358d8d6.tar.gz
home-manager-config-41bdeb88009dd232808edee9fc0e4ae94358d8d6.zip
refactor: moving script into modules that makes sense
- instead of collecting all scripts into modules/scripts we are moving them to modules that makes sense (yazi-file-chooser.sh into yazi)
Diffstat (limited to 'modules/security/gpg/default.nix')
-rw-r--r--modules/security/gpg/default.nix61
1 files changed, 43 insertions, 18 deletions
diff --git a/modules/security/gpg/default.nix b/modules/security/gpg/default.nix
index 472270b..07d9d4b 100644
--- a/modules/security/gpg/default.nix
+++ b/modules/security/gpg/default.nix
@@ -5,6 +5,27 @@
pkgs,
...
}:
+let
+ inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule;
+ gpgBackup = mkScriptModule {
+ scope = [
+ "security"
+ "gpg"
+ ];
+ name = "gpg-backup";
+ path = ./gpg-backup.sh;
+ description = "Export/import all GPG keys as a single passphrase-protected file with maximum S2K iteration count\nUsage: gpg-backup export filename.gpg | gpg-backup import filename.gpg";
+ deps = [
+ pkgs.bash
+ pkgs.gnupg
+ pkgs.gnutar
+ pkgs.coreutils
+ pkgs.findutils
+ ];
+ completion.zsh = builtins.readFile ./gpg-backup.zsh;
+ inherit config;
+ };
+in
{
options.security.gpg = {
enable = lib.mkEnableOption "Enables gpg.";
@@ -16,25 +37,29 @@
defaultText = lib.literalExpression "config.programs.gpg.package";
description = "The gpg package to use.";
};
- };
+ }
+ // gpgBackup.options.security.gpg;
- config = lib.mkIf config.security.gpg.enable {
- programs.gpg = {
- enable = true;
- homedir = "${config.xdg.dataHome}/gnupg";
- };
+ config = lib.mkMerge [
+ (lib.mkIf config.security.gpg.enable {
+ programs.gpg = {
+ enable = true;
+ homedir = "${config.xdg.dataHome}/gnupg";
+ };
- home.sessionVariables = {
- GNUPGHOME = config.programs.gpg.homedir;
- };
+ home.sessionVariables = {
+ GNUPGHOME = config.programs.gpg.homedir;
+ };
- services.gpg-agent = {
- enable = true;
- enableZshIntegration = true;
- defaultCacheTtl = 3600;
- maxCacheTtl = 86400;
- enableSshSupport = config.security.ssh.enable;
- pinentry.package = pkgs.pinentry-rofi;
- };
- };
+ services.gpg-agent = {
+ enable = true;
+ enableZshIntegration = true;
+ defaultCacheTtl = 3600;
+ maxCacheTtl = 86400;
+ enableSshSupport = config.security.ssh.enable;
+ pinentry.package = pkgs.pinentry-rofi;
+ };
+ })
+ gpgBackup.config
+ ];
}