mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
tomat: init service (#8138)
This commit is contained in:
parent
ba15db2a15
commit
2907788315
6 changed files with 127 additions and 0 deletions
9
modules/misc/news/2025/11/2025-11-06_12-50-53.nix
Normal file
9
modules/misc/news/2025/11/2025-11-06_12-50-53.nix
Normal 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.
|
||||
'';
|
||||
}
|
||||
74
modules/services/tomat.nix
Normal file
74
modules/services/tomat.nix
Normal 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" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
5
tests/modules/services/tomat/default.nix
Normal file
5
tests/modules/services/tomat/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
tomat-service = ./tomat.nix;
|
||||
}
|
||||
3
tests/modules/services/tomat/expected-config.toml
Normal file
3
tests/modules/services/tomat/expected-config.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[timer]
|
||||
break = 10
|
||||
work = 60
|
||||
11
tests/modules/services/tomat/expected.service
Normal file
11
tests/modules/services/tomat/expected.service
Normal 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
|
||||
25
tests/modules/services/tomat/tomat.nix
Normal file
25
tests/modules/services/tomat/tomat.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue