2022-05-01 16:27:04 +02: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-02-18 23:14:41 +01: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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-01 16:27:04 +02:00
|
|
|
in {
|
2024-02-18 23:14:41 +01: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.teadleer.settings.updates.auto_update = true`
|
|
|
|
|
|
|
|
instead, to make sure tealdeer's cache is updated periodically.
|
|
|
|
'')
|
|
|
|
];
|
2022-05-01 16:27:04 +02:00
|
|
|
|
|
|
|
options.programs.tealdeer = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "Tealdeer";
|
2022-05-01 16:27:04 +02:00
|
|
|
|
|
|
|
settings = mkOption {
|
2024-02-18 23:14:41 +01:00
|
|
|
type = types.nullOr settingsFormat;
|
|
|
|
default = null;
|
2022-05-01 16:27:04 +02:00
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
display = {
|
|
|
|
compact = false;
|
|
|
|
use_pager = true;
|
|
|
|
};
|
|
|
|
updates = {
|
|
|
|
auto_update = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2022-05-01 16:27:04 +02:00
|
|
|
Configuration written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/tealdeer/config.toml` on Linux or
|
2024-02-18 23:14:41 +01:00
|
|
|
{file}`$HOME/Library/Application Support/tealdeer/config.toml` on Darwin.
|
|
|
|
See <https://dbrgn.github.io/tealdeer/config.html> for more information.
|
2022-05-01 16:27:04 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ pkgs.tealdeer ];
|
|
|
|
|
2024-02-18 23:14:41 +01:00
|
|
|
home.file."${configDir}/tealdeer/config.toml" =
|
|
|
|
mkIf (cfg.settings != null && cfg.settings != { }) {
|
|
|
|
source = tomlFormat.generate "tealdeer-config" cfg.settings;
|
|
|
|
};
|
2022-05-01 16:27:04 +02:00
|
|
|
};
|
|
|
|
}
|