{ config, lib, pkgs, ... }: with lib; let cfg = config.services.ubino; in { options.services.ubino = { enable = mkEnableOption "Ubino: assistente virtuale di Ube, sottoforma di bot di Telegram."; user = mkOption { type = types.str; default = "ubino"; description = '' Ubino will be run under this user (user will be created if it doesn't exist. This can be your user name). ''; }; }; config = mkIf cfg.enable { users.groups.ubino = {}; users.extraUsers."${cfg.user}" = { isSystemUser = true; group = "ubino"; description = "Ubino user"; }; systemd.services.ubino = { description = "Ubino: assistente virtuale di Ube, sottoforma di bot di Telegram."; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { User = cfg.user; Group = "ubino"; ExecStart = "${pkgs.openjdk}/bin/java -jar UbinoBot.jar"; Restart = "always"; StateDirectory = "ubino"; WorkingDirectory = "%S/ubino"; }; }; }; }