2023-01-10 09:35:00 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.tealdeer;
|
|
|
|
|
|
|
|
configDir = if pkgs.stdenv.isDarwin then
|
|
|
|
"Library/Application Support"
|
|
|
|
else
|
|
|
|
config.xdg.configHome;
|
|
|
|
|
2024-06-04 18:23:39 +00:00
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
settingsFormat = let
|
|
|
|
updatesSection = types.submodule {
|
|
|
|
options = {
|
|
|
|
auto_update = mkEnableOption "auto-update";
|
|
|
|
|
|
|
|
auto_update_interval_hours = mkOption {
|
|
|
|
type = types.ints.positive;
|
|
|
|
default = 720;
|
|
|
|
example = literalExpression "24";
|
|
|
|
description = ''
|
|
|
|
Duration, since the last cache update, after which the cache will be refreshed.
|
|
|
|
This parameter is ignored if {var}`auto_update` is set to `false`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in types.submodule {
|
|
|
|
freeformType = tomlFormat.type;
|
|
|
|
options = {
|
|
|
|
updates = mkOption {
|
|
|
|
type = updatesSection;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
Tealdeer can refresh the cache automatically when it is outdated.
|
|
|
|
This behavior can be configured in the updates section.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
in {
|
2024-06-04 18:23:39 +00:00
|
|
|
meta.maintainers = [ hm.maintainers.pedorich-n ];
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [ "programs" "tealdeer" "updateOnActivation" ] ''
|
|
|
|
Updating tealdeer's cache requires network access.
|
|
|
|
The activation script should be fast and idempotent, so the option was removed.
|
|
|
|
Please use
|
|
|
|
|
|
|
|
`programs.tealdeer.settings.updates.auto_update = true`
|
|
|
|
|
|
|
|
instead, to make sure tealdeer's cache is updated periodically.
|
|
|
|
'')
|
|
|
|
];
|
2023-01-10 09:35:00 +00:00
|
|
|
|
|
|
|
options.programs.tealdeer = {
|
|
|
|
enable = mkEnableOption "Tealdeer";
|
|
|
|
|
|
|
|
settings = mkOption {
|
2024-06-04 18:23:39 +00:00
|
|
|
type = types.nullOr settingsFormat;
|
|
|
|
default = null;
|
2023-01-10 09:35:00 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
display = {
|
|
|
|
compact = false;
|
|
|
|
use_pager = true;
|
|
|
|
};
|
|
|
|
updates = {
|
|
|
|
auto_update = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Configuration written to
|
2023-08-08 10:19:01 +00:00
|
|
|
{file}`$XDG_CONFIG_HOME/tealdeer/config.toml` on Linux or
|
2024-06-04 18:23:39 +00:00
|
|
|
{file}`$HOME/Library/Application Support/tealdeer/config.toml` on Darwin.
|
|
|
|
See <https://dbrgn.github.io/tealdeer/config.html> for more information.
|
2023-01-10 09:35:00 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ pkgs.tealdeer ];
|
|
|
|
|
2024-06-04 18:23:39 +00:00
|
|
|
home.file."${configDir}/tealdeer/config.toml" =
|
|
|
|
mkIf (cfg.settings != null && cfg.settings != { }) {
|
|
|
|
source = tomlFormat.generate "tealdeer-config" cfg.settings;
|
|
|
|
};
|
2023-01-10 09:35:00 +00:00
|
|
|
};
|
|
|
|
}
|