1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

tomat: init service (#8138)

This commit is contained in:
Johan Larsson 2025-11-06 17:44:08 +01:00 committed by GitHub
parent ba15db2a15
commit 2907788315
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 127 additions and 0 deletions

View file

@ -0,0 +1,9 @@
{
time = "2025-11-06T11:50:53+00:00";
condition = true;
message = ''
A new module is available: 'services.tomat'.
tomat is a Pomodoro timer for status bars and the command line. It is easily configurable and support both desktop and sound notifications.
'';
}

View file

@ -0,0 +1,74 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.tomat;
tomlFormat = pkgs.formats.toml { };
in
{
meta.maintainers = with lib.maintainers; [ jolars ];
options.services.tomat = {
enable = lib.mkEnableOption "Tomat Pomodoro server";
package = lib.mkPackageOption pkgs "tomat" { };
settings = lib.mkOption {
type = lib.types.submodule { freeformType = tomlFormat.type; };
default = { };
example = {
timer = {
work = 25;
break = 5;
auto_advance = false;
};
sound = {
enabled = true;
};
notification = {
enabled = true;
};
};
description = ''
Tomat configuration.
See <https://github.com/jolars/tomat/blob/main/docs/configuration.md> for supported values.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile = {
"tomat/config.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "tomat-config.toml" cfg.settings;
};
};
systemd.user.services.tomat = {
Unit = {
Description = "Tomat Pomodoro server";
After = [ "graphical.target" ];
};
Service = {
ExecStart = "${lib.getExe cfg.package} daemon run";
Restart = "always";
RestartSec = 5;
};
Install = {
WantedBy = [ "default.target" ];
};
};
};
}

View file

@ -0,0 +1,5 @@
{ lib, pkgs, ... }:
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
tomat-service = ./tomat.nix;
}

View file

@ -0,0 +1,3 @@
[timer]
break = 10
work = 60

View file

@ -0,0 +1,11 @@
[Install]
WantedBy=default.target
[Service]
ExecStart=@tomat@/bin/tomat daemon run
Restart=always
RestartSec=5
[Unit]
After=graphical.target
Description=Tomat Pomodoro server

View file

@ -0,0 +1,25 @@
{
services.tomat = {
enable = true;
settings = {
timer = {
break = 10;
work = 60;
};
};
};
nmt.script =
let
serviceFile = "home-files/.config/systemd/user/tomat.service";
configFile = "home-files/.config/tomat/config.toml";
in
''
assertFileExists "${serviceFile}"
assertFileExists "${configFile}"
assertFileContent "${serviceFile}" ${./expected.service}
assertFileContent "${configFile}" ${./expected-config.toml}
'';
}