From 44b8624d201e70c8418ada5db3c46e9ba130ea30 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Thu, 24 Sep 2026 03:42:34 +0530 Subject: refactor(naming): use kebab-case option names and consistent gopass secret naming --- .../communication/neomutt/account/assertions.nix | 4 +- modules/communication/neomutt/account/default.nix | 26 +++++----- .../neomutt/account/flavors/gmail/default.nix | 2 +- modules/communication/neomutt/account/options.nix | 20 ++++---- modules/communication/senpai/assertions.nix | 5 +- modules/communication/senpai/default.nix | 57 ++++++++++++++-------- 6 files changed, 66 insertions(+), 48 deletions(-) (limited to 'modules/communication') diff --git a/modules/communication/neomutt/account/assertions.nix b/modules/communication/neomutt/account/assertions.nix index c19ab72..5c30311 100644 --- a/modules/communication/neomutt/account/assertions.nix +++ b/modules/communication/neomutt/account/assertions.nix @@ -5,12 +5,12 @@ { assertion = !config.communication.neomutt.enable - || !lib.any (account: account.enable && account.passwordGopassSecret != null) ( + || !lib.any (account: account.enable && account.password-gopass-secret != null) ( lib.attrValues config.communication.neomutt.accounts ) || config.security.gopass.enable; message = '' - An enabled communication.neomutt account uses passwordGopassSecret but security.gopass.enable is not set. + An enabled communication.neomutt account uses password-gopass-secret but security.gopass.enable is not set. Enable security.gopass to provide the account password command. ''; } diff --git a/modules/communication/neomutt/account/default.nix b/modules/communication/neomutt/account/default.nix index e2d92eb..61256e1 100644 --- a/modules/communication/neomutt/account/default.nix +++ b/modules/communication/neomutt/account/default.nix @@ -21,17 +21,19 @@ config = lib.mkIf config.communication.neomutt.enable { accounts.email.accounts = lib.mapAttrs (accountName: accountInformation: { - inherit (accountInformation) realName address primary; + inherit (accountInformation) address primary; + + realName = accountInformation.real-name; userName = - if accountInformation.userName != null then - accountInformation.userName + if accountInformation.username != null then + accountInformation.username else accountInformation.address; passwordCommand = - if accountInformation.passwordGopassSecret != null then - "${lib.getExe config.security.gopass.package} -o ${accountInformation.passwordGopassSecret}" + if accountInformation.password-gopass-secret != null then + "${lib.getExe config.security.gopass.package} -o ${accountInformation.password-gopass-secret}" else null; @@ -50,7 +52,7 @@ neomutt = { enable = true; - mailboxType = accountInformation.neomutt.mailboxType; + mailboxType = accountInformation.neomutt.mailbox-type; extraConfig = accountInformation.neomutt.extraConfig; }; @@ -71,7 +73,7 @@ enable = true; neomutt = { enable = true; - virtualMailboxes = accountInformation.notmuch.neomutt.virtualMailboxes; + virtualMailboxes = accountInformation.notmuch.neomutt.virtual-mailboxes; }; }; @@ -80,7 +82,7 @@ port = accountInformation.imap.port; tls = { enable = accountInformation.imap.tls.enable; - useStartTls = accountInformation.imap.tls.useStartTls; + useStartTls = accountInformation.imap.tls.use-start-tls; }; }; @@ -89,14 +91,14 @@ port = accountInformation.smtp.port; tls = { enable = accountInformation.smtp.tls.enable; - useStartTls = accountInformation.smtp.tls.useStartTls; + useStartTls = accountInformation.smtp.tls.use-start-tls; }; }; gpg = lib.optionalAttrs (accountInformation.gpg.key != null) { key = accountInformation.gpg.key; - signByDefault = accountInformation.gpg.signByDefault; - encryptByDefault = accountInformation.gpg.encryptByDefault; + signByDefault = accountInformation.gpg.sign-by-default; + encryptByDefault = accountInformation.gpg.encrypt-by-default; }; signature = @@ -105,7 +107,7 @@ { text = accountInformation.signature.text; command = accountInformation.signature.command; - showSignature = accountInformation.signature.showSignature; + showSignature = accountInformation.signature.show-signature; }; }) (lib.filterAttrs (n: a: a.enable) config.communication.neomutt.accounts); }; diff --git a/modules/communication/neomutt/account/flavors/gmail/default.nix b/modules/communication/neomutt/account/flavors/gmail/default.nix index 66d7db3..5b3c098 100644 --- a/modules/communication/neomutt/account/flavors/gmail/default.nix +++ b/modules/communication/neomutt/account/flavors/gmail/default.nix @@ -32,7 +32,7 @@ neomutt.extraConfig = lib.mkBefore (builtins.readFile ./.muttrc); - notmuch.neomutt.virtualMailboxes = lib.mkDefault [ + notmuch.neomutt.virtual-mailboxes = lib.mkDefault [ { name = "All Mail"; query = "folder:${name}/Inbox or folder:\"${name}/[Gmail]/Sent Mail\""; diff --git a/modules/communication/neomutt/account/options.nix b/modules/communication/neomutt/account/options.nix index 45e6744..676f8b0 100644 --- a/modules/communication/neomutt/account/options.nix +++ b/modules/communication/neomutt/account/options.nix @@ -6,7 +6,7 @@ default = true; }; - realName = lib.mkOption { + real-name = lib.mkOption { type = lib.types.str; description = "Name displayed when sending mails."; }; @@ -16,13 +16,13 @@ description = "Email address of this account."; }; - userName = lib.mkOption { + username = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; description = "Server username. Defaults to address if null."; }; - passwordGopassSecret = lib.mkOption { + password-gopass-secret = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; description = "Gopass secret path (e.g. mail/user@gmail.com). Constructs passwordCommand automatically."; @@ -81,7 +81,7 @@ }; neomutt = { - mailboxType = lib.mkOption { + mailbox-type = lib.mkOption { type = lib.types.enum [ "maildir" "imap" @@ -178,7 +178,7 @@ notmuch = { neomutt = { - virtualMailboxes = lib.mkOption { + virtual-mailboxes = lib.mkOption { type = lib.types.listOf ( lib.types.submodule { options = { @@ -237,7 +237,7 @@ description = "Enable TLS."; }; - useStartTls = lib.mkOption { + use-start-tls = lib.mkOption { type = lib.types.bool; default = false; description = "Use STARTTLS."; @@ -265,7 +265,7 @@ description = "Enable TLS."; }; - useStartTls = lib.mkOption { + use-start-tls = lib.mkOption { type = lib.types.bool; default = false; description = "Use STARTTLS."; @@ -280,13 +280,13 @@ description = "GPG key to use."; }; - signByDefault = lib.mkOption { + sign-by-default = lib.mkOption { type = lib.types.bool; default = false; description = "Sign messages by default."; }; - encryptByDefault = lib.mkOption { + encrypt-by-default = lib.mkOption { type = lib.types.bool; default = false; description = "Encrypt messages by default."; @@ -306,7 +306,7 @@ description = "Command that generates a signature."; }; - showSignature = lib.mkOption { + show-signature = lib.mkOption { type = lib.types.nullOr ( lib.types.enum [ "append" diff --git a/modules/communication/senpai/assertions.nix b/modules/communication/senpai/assertions.nix index ed2cce8..8e74367 100644 --- a/modules/communication/senpai/assertions.nix +++ b/modules/communication/senpai/assertions.nix @@ -13,8 +13,9 @@ } { assertion = - config.communication.senpai.identity.passwordGopassSecret == null || config.security.gopass.enable; - message = "communication.senpai.identity.passwordGopassSecret requires security.gopass.enable."; + config.communication.senpai.identity.password-gopass-secret == null + || config.security.gopass.enable; + message = "communication.senpai.identity.password-gopass-secret requires security.gopass.enable."; } ]; } diff --git a/modules/communication/senpai/default.nix b/modules/communication/senpai/default.nix index 56bb7ab..49f82d9 100644 --- a/modules/communication/senpai/default.nix +++ b/modules/communication/senpai/default.nix @@ -5,6 +5,9 @@ pkgs, ... }: +let + cfg = config.communication.senpai; +in { imports = [ ./assertions.nix ]; @@ -17,48 +20,60 @@ description = "The senpai package to use."; }; - server = { - address = lib.mkOption { - type = lib.types.str; - description = "IRC server address (host[:port]). Supports irc://, ircs://, irc+insecure:// URLs."; + server = lib.mkOption { + type = lib.types.submodule { + options = { + address = lib.mkOption { + type = lib.types.str; + description = "IRC server address (host[:port]). Supports irc://, ircs://, irc+insecure:// URLs."; + }; + }; }; + default = { }; + description = "IRC server configuration."; }; - identity = { - nickname = lib.mkOption { - type = lib.types.str; - description = "Your IRC nickname (no spaces or colons)."; - }; + identity = lib.mkOption { + type = lib.types.submodule { + options = { + nickname = lib.mkOption { + type = lib.types.str; + description = "Your IRC nickname (no spaces or colons)."; + }; - passwordGopassSecret = lib.mkOption { - type = lib.types.nullOr lib.types.str; - default = null; - description = "Gopass secret path for SASL password (e.g. irc/user@server). Constructs password-cmd automatically."; + password-gopass-secret = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Gopass secret path for SASL password (e.g. irc/user@server). Constructs password-cmd automatically."; + }; + }; }; + default = { }; + description = "Identity configuration."; }; }; config = lib.mkMerge [ - (lib.mkIf config.communication.senpai.enable { + (lib.mkIf cfg.enable { programs.senpai = { enable = true; - package = config.communication.senpai.package; + package = cfg.package; config = { - address = config.communication.senpai.server.address; - nickname = config.communication.senpai.identity.nickname; - password-cmd = lib.mkIf (config.communication.senpai.identity.passwordGopassSecret != null) [ + address = cfg.server.address; + nickname = cfg.identity.nickname; + password-cmd = lib.mkIf (cfg.identity.password-gopass-secret != null) [ (lib.getExe config.security.gopass.package) "show" "-o" - config.communication.senpai.identity.passwordGopassSecret + cfg.identity.password-gopass-secret ]; }; }; }) - (lib.mkIf (config.communication.senpai.enable && config.terminal.kitty.enable) { + (lib.mkIf (cfg.enable && config.terminal.kitty.enable) { xdg.desktopEntries."senpai" = { name = "Senpai"; - exec = "${lib.getExe config.terminal.kitty.package} --class senpai -e ${lib.getExe config.communication.senpai.package}"; + exec = "${lib.getExe config.terminal.kitty.package} --class senpai -e ${lib.getExe cfg.package}"; icon = "senpai"; categories = [ "Network" -- cgit v1.2.3