1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 11:19:47 +01:00

todoman: use ini format for settings

Use ini format to generate config
This commit is contained in:
Mikilio 2024-04-10 21:08:59 +02:00
parent 0055eeafb6
commit 296e5d371e
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F

View file

@ -5,6 +5,7 @@ with lib;
let let
cfg = config.programs.todoman; cfg = config.programs.todoman;
iniFormat = pkgs.formats.ini { };
in { in {
@ -21,108 +22,55 @@ in {
The glob expansion which matches all directories relevant. The glob expansion which matches all directories relevant.
''; '';
}; };
settings = mkOption {
color = mkOption { type = iniFormat.type;
type = types.nullOr (types.enum [ "never" "always" ]); default = { };
default = null;
description = '' description = ''
By default todoman will disable colored output if stdout is not a TTY. Configuration for todoman
Set to never to disable colored output entirely, or always to enable it regardless.
See [docs](`https://todoman.readthedocs.io/en/stable/man.html#id5`).
for the full list of options.
'';
example = literalExpression ''
{
date_format = "%Y-%m-%d";
time_format = "%H:%M";
default_list = "Personal";
default_due = 48;
};
''; '';
}; };
dateformat = mkOption { extraConfig = mkOption {
type = types.nullOr types.str; type = types.lines;
default = null; default = "";
description = '' description = ''
The date format used both for displaying dates, and parsing input Additional lines for configuration of todoman
dates. If this option is not specified the system locales is used.
'';
};
defaultDue = mkOption { See [docs](`https://todoman.readthedocs.io/en/stable/man.html#id5`).
type = types.nullOr types.int; for the full list of options.
default = null;
description = ''
The default difference (in hours) between new todos due date and
creation date. If not specified, the value is 24. If set to 0,
the due date for new todos will not be set.
'';
};
defaultList = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The default list for adding a todo. If you do not specify this option,
you must use the `--list` / `-l` option every time you add a todo.
'';
};
defaultPriority = mkOption {
type = types.nullOr types.int;
default = null;
description = ''
The default priority of a task on creation. Highest priority is 1,
lowest priority is 10, and 0 means no priority at all.
'';
};
dtSeparator = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The string used to separate date and time when displaying and parsing.
'';
};
humanize = mkOption {
type = types.bool;
default = false;
description = ''
If set to true, datetimes will be printed in human friendly formats like
tomorrow, in one hour, 3 weeks ago, etc.
'';
};
startable = mkOption {
type = types.bool;
default = false;
description = ''
If set to true, only show todos which are currently startable;
these are todos which have a start date today, or some day in the past.
Todos with no start date are always considered current. Incomplete todos
(eg: partially-complete) are also included.
'';
};
timeformat = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The date format used both for displaying times, and parsing input times.
If this option is not specified the system locales is used.
''; '';
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ assertions = [{
{ assertion = accounts.calendar ? basePath;
assertion = accounts.calendar ? basePath; message = ''
message = '' A base directory for calendars must be specified via
A base directory for calendars must be specified via `accounts.calendar.basePath` to generate config for todoman
`accounts.calendar.basePath` to generate config for todoman '';
''; }];
}
{
assertion = 0 <= cfg.defaultPriority && cfg.defaultPriority <= 10;
message = "Todoman's `defaultPriority` must be between 0 and 10.";
}
];
home.packages = [ pkgs.todoman ]; home.packages = [ pkgs.todoman ];
xdg.configFile."todoman/config.py".text = generators.toINI cfg; xdg.configFile."todoman/config.py" =
mkIf (cfg.settings != { } && cfg.extraConfig != "") {
text = lib.concatLines [
''path = "~/${config.accounts.calendar.basePath}${cfg.glob}"''
(generators.toINI { } cfg.settings)
cfg.extraConfig
];
};
}; };
} }