fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6cfg = config . services . fnott ; 7 8concatStringsSep' = sep :list :concatStringsSep sep ( remove "" list ); 9 10iniFormat = pkgs . formats . ini { }; 11in { 12meta . maintainers = with maintainers ; [ polykernel ]; 13 14options = { 15services . fnott = { 16enable = mkEnableOption '' 17fnott, a lightweight Wayland notification daemon for wlroots-based compositors 18'' ; 19 20package = mkOption { 21type = types . package ; 22default = pkgs . fnott ; 23defaultText = literalExpression "pkgs.fnott" ; 24description = "Package providing {command}`fnott`." ; 25}; 26 27extraFlags = mkOption { 28type = types . listOf types . str ; 29default = [ ]; 30example = [ "-s" ]; 31description = '' 32Extra arguments to use for executing fnott. 33'' ; 34}; 35 36configFile = mkOption { 37type = types . either types . str types . path ; 38default = " ${ config . xdg . configHome } /fnott/fnott.ini" ; 39defaultText = "$XDG_CONFIG_HOME/fnott/fnott.ini" ; 40description = '' 41Path to the configuration file read by fnott. 42 43Note that environment variables in the path won't be properly expanded. 44 45The configuration specified under 46{option}`services.fnott.settings` will be generated and 47written to {file}`$XDG_CONFIG_HOME/fnott/fnott.ini` 48regardless of this option. This allows using a mutable configuration file 49generated from the immutable one, useful in scenarios where live reloading is desired. 50'' ; 51}; 52 53settings = mkOption { 54type = iniFormat . type ; 55default = { }; 56description = '' 57Configuration written to 58{file}`$XDG_CONFIG_HOME/fnott/fnott.ini`. 59 60See 61{manpage}`fnott.ini(5)` for a list of available options and <https://codeberg.org/dnkl/fnott/src/branch/master/fnott.ini> 62for an example configuration. 63'' ; 64example = literalExpression '' 65{ 66main = { 67notification-margin = 5; 68}; 69 70low = { 71timeout = 5; 72title-font = "Dina:weight=bold:slant=italic"; 73title-color = "ffffff"; 74}; 75} 76'' ; 77}; 78}; 79}; 80 81config = mkIf cfg . enable { 82assertions = 83[ ( hm . assertions . assertPlatform "services.fnott" pkgs platforms . linux ) ]; 84 85home . packages = [ cfg . package ]; 86 87systemd . user . services . fnott = { 88Unit = { 89Description = "Fnott notification daemon" ; 90Documentation = "man:fnott(1)" ; 91After = [ "graphical-session-pre.target" ]; 92PartOf = [ "graphical-session.target" ]; 93}; 94 95Service = { 96Type = "dbus" ; 97BusName = "org.freedesktop.Notifications" ; 98ExecStart = concatStringsSep' " " [ 99" ${ cfg . package } /bin/fnott" 100"-c ${ escapeShellArg cfg . configFile } " 101( escapeShellArgs cfg . extraFlags ) 102]; 103}; 104}; 105 106xdg . dataFile . "dbus-1/services/fnott.service" . text = '' 107[D-BUS Service] 108Name=org.freedesktop.Notifications 109Exec= ${ cfg . package } /bin/fnott 110SystemdService=fnott.service 111'' ; 112 113xdg . configFile . "fnott/fnott.ini" . source = 114iniFormat . generate "fnott.ini" cfg . settings ; 115}; 116}