fork/home-manager
git clone https://git.julia.blue/fork/home-manager
e0034971
master
1{ config , lib , pkgs , ...} : 2 3let 4cfg = config . services . comodoro ; 5 6args = with cfg ; { 7inherit preset ; 8protocols = if lib . isList protocols then 9lib . concatStringsSep " " protocols 10else 11protocols ; 12}; 13 14in { 15meta . maintainers = with lib . hm . maintainers ; [ soywod ]; 16 17options . services . comodoro = { 18enable = lib . mkEnableOption "Comodoro server" ; 19 20package = lib . mkPackageOption pkgs "comodoro" { }; 21 22environment = lib . mkOption { 23type = with lib . types ; attrsOf str ; 24default = { }; 25example = lib . literalExpression '' 26{ 27"PASSWORD_STORE_DIR" = "~/.password-store"; 28} 29'' ; 30description = '' 31Extra environment variables to be exported in the service. 32'' ; 33}; 34 35preset = lib . mkOption { 36type = lib . types . nonEmptyStr ; 37description = '' 38Use configuration from the given preset as defined in the configuration file. 39'' ; 40}; 41 42protocols = lib . mkOption { 43type = with lib . types ; nonEmptyListOf nonEmptyStr ; 44description = '' 45Define protocols the server should use to accept requests. 46'' ; 47}; 48}; 49 50config = lib . mkIf cfg . enable { 51home . packages = [ cfg . package ]; 52 53systemd . user . services . comodoro = { 54Unit = { 55Description = "Comodoro server" ; 56After = [ "network.target" ]; 57}; 58Install = { WantedBy = [ "default.target" ]; }; 59Service = { 60ExecStart = with args ; 61" ${ cfg . package } /bin/comodoro server start ${ preset } ${ protocols } " ; 62ExecSearchPath = "/bin" ; 63Restart = "always" ; 64RestartSec = 10 ; 65Environment = 66lib . mapAttrsToList ( key :val :" ${ key } = ${ val } " ) cfg . environment ; 67}; 68}; 69}; 70}