Skip to content
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
20 changes: 11 additions & 9 deletions modules/programs/jrnl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ let
cfg = config.programs.jrnl;
yamlFormat = pkgs.formats.yaml { };
in
with lib;
{
meta.maintainers = [ lib.maintainers.matthiasbeyer ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add yourself here as well!


options.programs.jrnl = {
enable = mkEnableOption "jrnl";
enable = lib.mkEnableOption "jrnl";

package = lib.mkPackageOption pkgs "jrnl" { nullable = true; };

settings = mkOption {
type = yamlFormat.type;
settings = lib.mkOption {
inherit (yamlFormat) type;
default = { };
description = ''
Configuration for the jrnl binary.
Expand All @@ -27,10 +28,11 @@ with lib;
};
};

config = mkIf cfg.enable {
home.packages = mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."jrnl/jrnl.yaml".source = yamlFormat.generate "jrnl.yaml" cfg.settings;
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];

meta.maintainers = [ lib.maintainers.matthiasbeyer ];
xdg.configFile."jrnl/jrnl.yaml" = lib.mkIf (cfg.settings != { }) {
source = yamlFormat.generate "jrnl.yaml" cfg.settings;
};
};
}
4 changes: 4 additions & 0 deletions tests/modules/programs/jrnl/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
jrnl-empty-settings = ./jrnl-empty-settings.nix;
jrnl-basic-settings = ./jrnl-basic-settings.nix;
}
18 changes: 18 additions & 0 deletions tests/modules/programs/jrnl/jrnl-basic-settings-expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
colors:
body: none
date: green
tags: yellow
title: cyan
default_hour: 9
default_minute: 0
editor: vim
encrypt: false
highlight: true
indent_character: '|'
journals:
default: ~/journals/journal.txt
work: ~/journals/work.txt
linewrap: 80
tagsymbols: '@'
template: false
timeformat: '%Y-%m-%d %H:%M'
32 changes: 32 additions & 0 deletions tests/modules/programs/jrnl/jrnl-basic-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
programs.jrnl = {
enable = true;
settings = {
journals = {
default = "~/journals/journal.txt";
work = "~/journals/work.txt";
};
colors = {
body = "none";
date = "green";
tags = "yellow";
title = "cyan";
};
default_hour = 9;
default_minute = 0;
editor = "vim";
encrypt = false;
highlight = true;
indent_character = "|";
linewrap = 80;
tagsymbols = "@";
template = false;
timeformat = "%Y-%m-%d %H:%M";
};
};

nmt.script = ''
assertFileExists home-files/.config/jrnl/jrnl.yaml
assertFileContent home-files/.config/jrnl/jrnl.yaml ${./jrnl-basic-settings-expected.yaml}
'';
}
9 changes: 9 additions & 0 deletions tests/modules/programs/jrnl/jrnl-empty-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
programs.jrnl = {
enable = true;
};

nmt.script = ''
assertPathNotExists home-files/.config/jrnl/jrnl.yaml
'';
}