1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-18 09:09:45 +01:00
home-manager/modules/programs/tealdeer.nix

94 lines
2.5 KiB
Nix
Raw Normal View History

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;
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 {
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
2024-04-22 22:38:46 +02:00
`programs.tealdeer.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 = {
enable = mkEnableOption "Tealdeer";
2022-05-01 16:27:04 +02:00
settings = mkOption {
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;
};
};
'';
description = ''
2022-05-01 16:27:04 +02:00
Configuration written to
{file}`$XDG_CONFIG_HOME/tealdeer/config.toml` on Linux or
{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 ];
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
};
}