diff options
| author | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 03:42:34 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 03:42:34 +0530 |
| commit | 44b8624d201e70c8418ada5db3c46e9ba130ea30 (patch) | |
| tree | ab960997bf8831d294dd84838523b358b7012ac5 /modules/office/calcurse | |
| parent | 30f8fea050f3242f0e6a2072779e706b5c8ceaf1 (diff) | |
| download | home-manager-config-44b8624d201e70c8418ada5db3c46e9ba130ea30.tar.gz home-manager-config-44b8624d201e70c8418ada5db3c46e9ba130ea30.zip | |
refactor(naming): use kebab-case option names and consistent gopass secret naming
Diffstat (limited to 'modules/office/calcurse')
| -rw-r--r-- | modules/office/calcurse/default.nix | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/modules/office/calcurse/default.nix b/modules/office/calcurse/default.nix index 6e3e855..7c1df5e 100644 --- a/modules/office/calcurse/default.nix +++ b/modules/office/calcurse/default.nix @@ -6,6 +6,8 @@ ... }: let + cfg = config.office.calcurse; + calcurseSync = pkgs.writeShellScriptBin "calcurse-sync" (builtins.readFile ./calcurse-sync.sh); calcurse = pkgs.symlinkJoin { @@ -16,13 +18,13 @@ let pkgs.libnotify ] ++ lib.optionals config.development.nixvim.enable [ config.development.nixvim.package ] - ++ lib.optionals config.office.calcurse.sync.enable [ calcurseSync ]; + ++ lib.optionals cfg.sync.enable [ calcurseSync ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' ${lib.optionalString config.development.nixvim.enable '' wrapProgram $out/bin/calcurse --set PAGER "nvim" ''} - ${lib.optionalString config.office.calcurse.sync.enable '' + ${lib.optionalString cfg.sync.enable '' wrapProgram $out/bin/calcurse-sync \ --prefix PATH : ${ lib.makeBinPath [ @@ -31,8 +33,8 @@ let pkgs.gnused ] } \ - ${lib.optionalString (config.office.calcurse.sync.remote != null) '' - --set CALCURSE_SYNC_REMOTE ${lib.escapeShellArg config.office.calcurse.sync.remote} + ${lib.optionalString (cfg.sync.remote != null) '' + --set CALCURSE_SYNC_REMOTE ${lib.escapeShellArg cfg.sync.remote} ''} ''} ''; @@ -52,35 +54,47 @@ in default = calcurse; description = "The calcurse package to use."; }; - sync = { - enable = lib.mkEnableOption "Enables git-backed syncing of the calcurse data directory (builds calcurse-sync, installs the sync hooks, and runs an initial 'calcurse-sync init' on activation)."; - remote = lib.mkOption { - type = lib.types.nullOr lib.types.str; - default = null; - description = "Git remote URL for the calcurse data directory. Use an https:// URL if 'credential' is configured. When set, calcurse-sync uses it automatically on first init instead of prompting."; - }; - credential = { - username = lib.mkOption { - type = lib.types.nullOr lib.types.str; - default = null; - description = "Username for HTTPS git authentication against the calcurse remote."; - }; - passwordGopassPath = lib.mkOption { - type = lib.types.nullOr lib.types.str; - default = null; - description = "gopass entry path holding the password or token used for HTTPS git authentication against the calcurse remote. E.g. 'git/calcurse-sync'."; + sync = lib.mkOption { + type = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Enables git-backed syncing of the calcurse data directory (builds calcurse-sync, installs the sync hooks, and runs an initial 'calcurse-sync init' on activation)."; + remote = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Git remote URL for the calcurse data directory. Use an https:// URL if 'credential' is configured. When set, calcurse-sync uses it automatically on first init instead of prompting."; + }; + credential = lib.mkOption { + type = lib.types.submodule { + options = { + username = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Username for HTTPS git authentication against the calcurse remote."; + }; + password-gopass-secret = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "gopass entry path holding the password or token used for HTTPS git authentication against the calcurse remote. E.g. 'git/calcurse-sync'."; + }; + }; + }; + default = { }; + description = "Credentials for HTTPS git authentication."; + }; }; }; + default = { }; + description = "Git-backed syncing configuration."; }; }; config = lib.mkMerge [ - (lib.mkIf config.office.calcurse.enable { + (lib.mkIf cfg.enable { home.file.".local/share/icons/hicolor/scalable/apps/calcurse.svg" = { source = ../../../assets/icons/apps/calcurse.svg; }; - home.packages = [ config.office.calcurse.package ]; + home.packages = [ cfg.package ]; xdg.configFile."calcurse/conf" = { text = builtins.replaceStrings [ "@@CALCURSE_ICON@@" ] [ "${../../../assets/icons/apps/calcurse.svg}" ] @@ -92,10 +106,10 @@ in force = true; }; }) - (lib.mkIf (config.office.calcurse.enable && config.terminal.kitty.enable) { + (lib.mkIf (cfg.enable && config.terminal.kitty.enable) { xdg.desktopEntries."calcurse" = { name = "calcurse"; - exec = "${lib.getExe config.terminal.kitty.package} --class calcurse -e ${lib.getExe config.office.calcurse.package}"; + exec = "${lib.getExe config.terminal.kitty.package} --class calcurse -e ${lib.getExe cfg.package}"; icon = "calcurse"; categories = [ "Office" @@ -106,7 +120,7 @@ in type = "Application"; }; }) - (lib.mkIf config.office.calcurse.sync.enable { + (lib.mkIf cfg.sync.enable { xdg.configFile."calcurse/hooks/pre-load" = { source = ./hooks/pre-load; executable = true; @@ -129,15 +143,15 @@ in commit.gpgSign = false; tag.gpgSign = false; } - // lib.optionalAttrs (config.office.calcurse.sync.credential.passwordGopassPath != null) { - credential.helper = "!f() { echo username=${lib.escapeShellArg config.office.calcurse.sync.credential.username}; echo password=\"$(${lib.getExe config.security.gopass.package} show -o ${lib.escapeShellArg config.office.calcurse.sync.credential.passwordGopassPath})\"; }; f"; + // lib.optionalAttrs (cfg.sync.credential.password-gopass-secret != null) { + credential.helper = "!f() { echo username=${lib.escapeShellArg cfg.sync.credential.username}; echo password=\"$(${lib.getExe config.security.gopass.package} show -o ${lib.escapeShellArg cfg.sync.credential.password-gopass-secret})\"; }; f"; }; } ]; - home.activation.calcurseSyncInit = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - run ${config.office.calcurse.package}/bin/calcurse-sync init || true - ''; + home.activation.calcurseSyncInit = lib.hm.dag.entryAfter [ "writeBoundary" ] ( + pkgs.writeText "calcurse-sync-init.sh" ("run " + cfg.package + "/bin/calcurse-sync init || true") + ); }) ]; } |
