53 lines
1.1 KiB
Nix
53 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.miguelbridge;
|
|
|
|
in {
|
|
|
|
options.services.miguelbridge = {
|
|
enable = mkEnableOption "miguelbridge: Bridge Telegram - Matrix.";
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "miguelbridge";
|
|
description = ''
|
|
miguelbridge 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.miguelbridge = {};
|
|
|
|
users.extraUsers."${cfg.user}" = {
|
|
isSystemUser = true;
|
|
group = "miguelbridge";
|
|
description = "miguelbridge user";
|
|
};
|
|
|
|
systemd.services.miguelbridge = {
|
|
description = "miguelbridge: Bridge Telegram - Matrix";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
User = cfg.user;
|
|
Group = "miguelbridge";
|
|
ExecStart = "${pkgs.openjdk}/bin/java -jar MiguelBridge.jar";
|
|
Restart = "always";
|
|
StateDirectory = "miguelbridge";
|
|
WorkingDirectory = "%S/miguelbridge";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|