2021-08-10 06:21:03 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.fnott;
|
|
|
|
|
2021-12-27 09:03:18 +01:00
|
|
|
concatStringsSep' = sep: list: concatStringsSep sep (remove "" list);
|
2021-08-10 06:21:03 +02:00
|
|
|
|
2021-10-15 05:39:01 +02:00
|
|
|
iniFormat = pkgs.formats.ini { };
|
2021-08-10 06:21:03 +02:00
|
|
|
in {
|
2021-11-21 05:54:00 +01:00
|
|
|
meta.maintainers = with maintainers; [ polykernel ];
|
|
|
|
|
2021-08-10 06:21:03 +02:00
|
|
|
options = {
|
|
|
|
services.fnott = {
|
2023-07-01 01:30:13 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc ''
|
2021-08-10 06:21:03 +02:00
|
|
|
fnott, a lightweight Wayland notification daemon for wlroots-based compositors
|
2023-07-01 01:30:13 +02:00
|
|
|
'');
|
2021-08-10 06:21:03 +02:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.fnott;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.fnott";
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc "Package providing {command}`fnott`.";
|
2021-08-10 06:21:03 +02:00
|
|
|
};
|
|
|
|
|
2021-08-28 05:01:24 +02:00
|
|
|
extraFlags = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "-s" ];
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2021-08-28 05:01:24 +02:00
|
|
|
Extra arguments to use for executing fnott.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-08-10 06:21:03 +02:00
|
|
|
configFile = mkOption {
|
|
|
|
type = types.either types.str types.path;
|
|
|
|
default = "${config.xdg.configHome}/fnott/fnott.ini";
|
|
|
|
defaultText = "$XDG_CONFIG_HOME/fnott/fnott.ini";
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2021-08-10 06:21:03 +02:00
|
|
|
Path to the configuration file read by fnott.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
2021-08-10 06:21:03 +02:00
|
|
|
Note that environment variables in the path won't be properly expanded.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
2022-06-15 15:49:39 +02:00
|
|
|
The configuration specified under
|
2023-07-01 01:30:13 +02:00
|
|
|
{option}`services.fnott.settings` will be generated and
|
|
|
|
written to {file}`$XDG_CONFIG_HOME/fnott/fnott.ini`
|
2021-08-10 06:21:03 +02:00
|
|
|
regardless of this option. This allows using a mutable configuration file
|
|
|
|
generated from the immutable one, useful in scenarios where live reloading is desired.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
2021-10-15 05:39:01 +02:00
|
|
|
type = iniFormat.type;
|
2021-08-10 06:21:03 +02:00
|
|
|
default = { };
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2021-08-10 06:21:03 +02:00
|
|
|
Configuration written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/fnott/fnott.ini`.
|
|
|
|
|
2021-08-10 06:21:03 +02:00
|
|
|
See
|
2023-07-01 01:30:13 +02:00
|
|
|
{manpage}`fnott.ini(5)` for a list of available options and <https://codeberg.org/dnkl/fnott/src/branch/master/fnott.ini>
|
2021-08-10 06:21:03 +02:00
|
|
|
for an example configuration.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-08-10 06:21:03 +02:00
|
|
|
{
|
|
|
|
main = {
|
|
|
|
notification-margin = 5;
|
|
|
|
};
|
|
|
|
|
|
|
|
low = {
|
|
|
|
timeout = 5;
|
|
|
|
title-font = "Dina:weight=bold:slant=italic";
|
|
|
|
title-color = "ffffff";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions =
|
|
|
|
[ (hm.assertions.assertPlatform "services.fnott" pkgs platforms.linux) ];
|
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
systemd.user.services.fnott = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Fnott notification daemon";
|
|
|
|
Documentation = "man:fnott(1)";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "org.freedesktop.Notifications";
|
|
|
|
ExecStart = concatStringsSep' " " [
|
2021-08-28 05:01:24 +02:00
|
|
|
"${cfg.package}/bin/fnott"
|
|
|
|
"-c ${escapeShellArg cfg.configFile}"
|
2021-08-10 06:21:03 +02:00
|
|
|
(escapeShellArgs cfg.extraFlags)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-20 15:48:56 +02:00
|
|
|
xdg.dataFile."dbus-1/services/fnott.service".text = ''
|
|
|
|
[D-BUS Service]
|
|
|
|
Name=org.freedesktop.Notifications
|
|
|
|
Exec=${cfg.package}/bin/fnott
|
|
|
|
SystemdService=fnott.service
|
|
|
|
'';
|
|
|
|
|
2021-10-15 05:39:01 +02:00
|
|
|
xdg.configFile."fnott/fnott.ini".source =
|
|
|
|
iniFormat.generate "fnott.ini" cfg.settings;
|
2021-08-10 06:21:03 +02:00
|
|
|
};
|
|
|
|
}
|