Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from nix-community:master #35

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@
github = "mainrs";
githubId = 5113257;
};
mikilio = {
name = "mikilio";
email = "[email protected]";
github = "mikilio";
githubId = 86004375;
};
kmaasrud = {
name = "Knut Magnus Aasrud";
email = "[email protected]";
Expand Down
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ let
./programs/tmate.nix
./programs/tmux.nix
./programs/tofi.nix
./programs/todoman.nix
./programs/topgrade.nix
./programs/translate-shell.nix
./programs/urxvt.nix
Expand Down
62 changes: 62 additions & 0 deletions modules/programs/todoman.nix
Original file line number Diff line number Diff line change
@@ -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.extraConfig
];
};
}
2 changes: 1 addition & 1 deletion modules/programs/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ in

''
${optionalString cfg.prezto.enable
(builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshrc")}
(builtins.readFile "${cfg.prezto.package}/share/zsh-prezto/runcoms/zshrc")}

${concatStrings (map (plugin: ''
if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then
Expand Down
12 changes: 7 additions & 5 deletions modules/programs/zsh/prezto.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ let
options = {
enable = mkEnableOption "prezto";

package = mkPackageOption pkgs "prezto" { default = "zsh-prezto"; };

caseSensitive = mkOption {
type = types.nullOr types.bool;
# See <https://github.com/nix-community/home-manager/issues/2255>.
Expand Down Expand Up @@ -379,15 +381,15 @@ in {
};
config = mkIf cfg.enable (mkMerge [{
home.file."${relToDotDir ".zprofile"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zprofile";
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zprofile";
home.file."${relToDotDir ".zlogin"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zlogin";
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zlogin";
home.file."${relToDotDir ".zlogout"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zlogout";
home.packages = with pkgs; [ zsh-prezto ];
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zlogout";
home.packages = [ cfg.package ];

home.file."${relToDotDir ".zshenv"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshenv";
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zshenv";
home.file."${relToDotDir ".zpreztorc"}".text = ''
# Generated by Nix
${optionalString (cfg.caseSensitive != null) ''
Expand Down
21 changes: 21 additions & 0 deletions tests/modules/programs/todoman/config.nix
Original file line number Diff line number Diff line change
@@ -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}
'';
}

1 change: 1 addition & 0 deletions tests/modules/programs/todoman/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ todoman-config = ./config.nix; }
3 changes: 3 additions & 0 deletions tests/modules/programs/todoman/todoman-config-expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
path = "/home/hm-user/base/path/calendar/*/*"
date_format = "%d.%m.%Y"
default_list = "test"
Loading