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 --- modules/office/calcurse/default.nix | 76 ++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'modules/office/calcurse/default.nix') 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") + ); }) ]; } -- cgit v1.2.3 From c5bdaefa94c3cd9bb7e55747f1682edef4168932 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Thu, 24 Sep 2026 03:48:37 +0530 Subject: chore: use lib.getExe and string activation data --- modules/file-management/yazi/default.nix | 2 +- modules/office/calcurse/default.nix | 6 +++--- modules/security/gopass/default.nix | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/office/calcurse/default.nix') diff --git a/modules/file-management/yazi/default.nix b/modules/file-management/yazi/default.nix index 3ba7045..72a4568 100644 --- a/modules/file-management/yazi/default.nix +++ b/modules/file-management/yazi/default.nix @@ -65,7 +65,7 @@ in }; home.file.".local/share/icons/hicolor/scalable/apps/yazi.png" = { - source = lib.file.mkOutOfStoreSymlink "${cfg.package}/share/pixmaps/yazi.png"; + source = config.lib.file.mkOutOfStoreSymlink "${cfg.package}/share/pixmaps/yazi.png"; }; home.sessionVariables = { diff --git a/modules/office/calcurse/default.nix b/modules/office/calcurse/default.nix index 7c1df5e..c4053da 100644 --- a/modules/office/calcurse/default.nix +++ b/modules/office/calcurse/default.nix @@ -149,9 +149,9 @@ in } ]; - home.activation.calcurseSyncInit = lib.hm.dag.entryAfter [ "writeBoundary" ] ( - pkgs.writeText "calcurse-sync-init.sh" ("run " + cfg.package + "/bin/calcurse-sync init || true") - ); + home.activation.calcurseSyncInit = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + run ${lib.getExe cfg.package} init || true + ''; }) ]; } diff --git a/modules/security/gopass/default.nix b/modules/security/gopass/default.nix index 17624ef..173318b 100644 --- a/modules/security/gopass/default.nix +++ b/modules/security/gopass/default.nix @@ -90,7 +90,7 @@ in }; } // lib.optionalAttrs (cfg.sync.enable && cfg.sync.credential.password-gopass-secret != null) { - credential.helper = "!f() { echo username=${lib.escapeShellArg cfg.sync.credential.username}; echo password=\"$(${cfg.package}/bin/gopass show -o ${lib.escapeShellArg cfg.sync.credential.password-gopass-secret})\"; }; f"; + credential.helper = "!f() { echo username=${lib.escapeShellArg cfg.sync.credential.username}; echo password=\"$(${lib.getExe cfg.package} show -o ${lib.escapeShellArg cfg.sync.credential.password-gopass-secret})\"; }; f"; }; } ]; -- cgit v1.2.3