{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.services.wrtagweb;
in
{
  options = {
    services.wrtagweb = {

      enable = lib.mkEnableOption "wrtag web";

      settingsFile = lib.mkOption {
        type = lib.types.path;
        description = ''
          Configuration file for wrtagweb
        '';
      };
    };
  };

  config = lib.mkIf cfg.enable {
    users.users.wrtagweb = {
      enable = true;
      isSystemUser = true;
      group = "wrtagweb";
    };
    users.groups.wrtagweb = { };

    environment.systemPackages = with pkgs; [
      rsgain
    ];

    systemd.services.wrtagweb = {
      description = "wrtagweb";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        User = "wrtagweb";
        ExecStart = "${pkgs.unstable.wrtag}/bin/wrtagweb -config-path ${cfg.settingsFile}";
      };
    };
  };
}
