aboutsummaryrefslogtreecommitdiffstats
path: root/modules/office/calcurse
diff options
context:
space:
mode:
Diffstat (limited to 'modules/office/calcurse')
-rw-r--r--modules/office/calcurse/default.nix72
1 files changed, 43 insertions, 29 deletions
diff --git a/modules/office/calcurse/default.nix b/modules/office/calcurse/default.nix
index 6e3e855..c4053da 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,14 +143,14 @@ 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
+ run ${lib.getExe cfg.package} init || true
'';
})
];