From 6f6587cbf639add9fd4f9cda5fa5109813a78a21 Mon Sep 17 00:00:00 2001 From: Mikilio Date: Wed, 10 Apr 2024 19:13:24 +0200 Subject: [PATCH 1/3] todoman: add todoman module Adds Mikilio as maintainer for new module for todoman a standards-based task manager based on iCalendar Apply suggestions from code review Co-authored-by: Robert Helgesson Update modules/programs/todoman.nix Co-authored-by: Robert Helgesson --- modules/lib/maintainers.nix | 6 ++++ modules/modules.nix | 1 + modules/programs/todoman.nix | 62 ++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 modules/programs/todoman.nix diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index b5175a87510a..fbe24658feae 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -424,6 +424,12 @@ github = "mainrs"; githubId = 5113257; }; + mikilio = { + name = "mikilio"; + email = "official.mikilio+dev@gmail.com"; + github = "mikilio"; + githubId = 86004375; + }; kmaasrud = { name = "Knut Magnus Aasrud"; email = "km@aasrud.com"; diff --git a/modules/modules.nix b/modules/modules.nix index e1b08087d146..f12d35abbf7f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -236,6 +236,7 @@ let ./programs/tmate.nix ./programs/tmux.nix ./programs/tofi.nix + ./programs/todoman.nix ./programs/topgrade.nix ./programs/translate-shell.nix ./programs/urxvt.nix diff --git a/modules/programs/todoman.nix b/modules/programs/todoman.nix new file mode 100644 index 000000000000..77ec3c5cf379 --- /dev/null +++ b/modules/programs/todoman.nix @@ -0,0 +1,62 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.todoman; + + format = pkgs.formats.keyValue { }; + +in { + + meta.maintainers = [ hm.maintainers.mikilio ]; + + options.programs.todoman = { + enable = lib.mkEnableOption "todoman"; + + glob = mkOption { + type = types.str; + default = "*"; + description = '' + The glob expansion which matches all directories relevant. + ''; + example = "*/*"; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Text for configuration of todoman. + The syntax is Python. + + See [docs](`https://todoman.readthedocs.io/en/stable/man.html#id5`). + for the full list of options. + ''; + example = '' + date_format = "%Y-%m-%d"; + time_format = "%H:%M"; + default_list = "Personal"; + default_due = 48; + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [{ + assertion = config.accounts.calendar ? basePath; + message = '' + A base directory for calendars must be specified via + `accounts.calendar.basePath` to generate config for todoman + ''; + }]; + + home.packages = [ pkgs.todoman ]; + + xdg.configFile."todoman/config.py".text = lib.concatLines [ + ''path = "${config.accounts.calendar.basePath}/${cfg.glob}"'' + cfg.config + ]; + }; +} From a270ff13a4bd6a2113eae6c813fd0d2e863d66b1 Mon Sep 17 00:00:00 2001 From: Mikilio Date: Sat, 1 Jun 2024 22:28:45 +0200 Subject: [PATCH 2/3] fix: correct config name --- modules/programs/todoman.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/todoman.nix b/modules/programs/todoman.nix index 77ec3c5cf379..2e7ebf6a22b5 100644 --- a/modules/programs/todoman.nix +++ b/modules/programs/todoman.nix @@ -56,7 +56,7 @@ in { xdg.configFile."todoman/config.py".text = lib.concatLines [ ''path = "${config.accounts.calendar.basePath}/${cfg.glob}"'' - cfg.config + cfg.extraConfig ]; }; } From 20e9a900998414879ad88cfe49f6ddd09d338fd1 Mon Sep 17 00:00:00 2001 From: Mikilio Date: Tue, 4 Jun 2024 19:16:38 +0200 Subject: [PATCH 3/3] chore: add test --- tests/modules/programs/todoman/config.nix | 21 +++++++++++++++++++ tests/modules/programs/todoman/default.nix | 1 + .../programs/todoman/todoman-config-expected | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 tests/modules/programs/todoman/config.nix create mode 100644 tests/modules/programs/todoman/default.nix create mode 100644 tests/modules/programs/todoman/todoman-config-expected diff --git a/tests/modules/programs/todoman/config.nix b/tests/modules/programs/todoman/config.nix new file mode 100644 index 000000000000..7323b7a43973 --- /dev/null +++ b/tests/modules/programs/todoman/config.nix @@ -0,0 +1,21 @@ +{ + programs.todoman = { + enable = true; + glob = "*/*"; + extraConfig = '' + date_format = "%d.%m.%Y" + default_list = "test" + ''; + }; + + accounts.calendar.basePath = "base/path/calendar"; + + test.stubs = { todoman = { }; }; + + nmt.script = '' + configFile=home-files/.config/todoman/config.py + assertFileExists $configFile + assertFileContent $configFile ${./todoman-config-expected} + ''; +} + diff --git a/tests/modules/programs/todoman/default.nix b/tests/modules/programs/todoman/default.nix new file mode 100644 index 000000000000..d429f9230d73 --- /dev/null +++ b/tests/modules/programs/todoman/default.nix @@ -0,0 +1 @@ +{ todoman-config = ./config.nix; } diff --git a/tests/modules/programs/todoman/todoman-config-expected b/tests/modules/programs/todoman/todoman-config-expected new file mode 100644 index 000000000000..00da13e1af89 --- /dev/null +++ b/tests/modules/programs/todoman/todoman-config-expected @@ -0,0 +1,3 @@ +path = "/home/hm-user/base/path/calendar/*/*" +date_format = "%d.%m.%Y" +default_list = "test"