<commit_before>{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.hardware.opentabletdriver;
in
{
  options = {
    hardware.opentabletdriver = {
      enable = mkOption {
        default = false;
        type = types.bool;
        description = ''
          Enable OpenTabletDriver udev rules, user service and blacklist kernel
          modules known to conflict with OpenTabletDriver.
        '';
      };

      blacklistedKernelModules = mkOption {
        type = types.listOf types.str;
        default = [ "hid-uclogic" "wacom" ];
        description = ''
          Blacklist of kernel modules known to conflict with OpenTabletDriver.
        '';
      };

      daemon = {
        enable = mkOption {
          default = true;
          type = types.bool;
          description = ''
            Whether to start OpenTabletDriver daemon as a systemd user service.
          '';
        };
      };
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = with pkgs; [ opentabletdriver ];

    services.udev.packages = with pkgs; [ opentabletdriver ];

    boot.blacklistedKernelModules = cfg.blacklistedKernelModules;

    systemd.user.services.opentabletdriver = with pkgs; mkIf cfg.daemon.enable {
      description = "Open source, cross-platform, user-mode tablet driver";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];

      serviceConfig = {
        Type = "simple";
        ExecStart = "${opentabletdriver}/bin/otd-daemon -c ${opentabletdriver}/lib/OpenTabletDriver/Configurations";
        Restart = "on-failure";
      };
    };
  };
}<commit_msg>nixos/opentabletdriver: add package option<commit_after>{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.hardware.opentabletdriver;
in
{
  options = {
    hardware.opentabletdriver = {
      enable = mkOption {
        default = false;
        type = types.bool;
        description = ''
          Enable OpenTabletDriver udev rules, user service and blacklist kernel
          modules known to conflict with OpenTabletDriver.
        '';
      };

      blacklistedKernelModules = mkOption {
        type = types.listOf types.str;
        default = [ "hid-uclogic" "wacom" ];
        description = ''
          Blacklist of kernel modules known to conflict with OpenTabletDriver.
        '';
      };

      package = mkOption {
        type = types.package;
        default = pkgs.opentabletdriver;
        defaultText = "pkgs.opentabletdriver";
        description = ''
          OpenTabletDriver derivation to use.
        '';
      };

      daemon = {
        enable = mkOption {
          default = true;
          type = types.bool;
          description = ''
            Whether to start OpenTabletDriver daemon as a systemd user service.
          '';
        };
      };
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

    services.udev.packages = [ cfg.package ];

    boot.blacklistedKernelModules = cfg.blacklistedKernelModules;

    systemd.user.services.opentabletdriver = with pkgs; mkIf cfg.daemon.enable {
      description = "Open source, cross-platform, user-mode tablet driver";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];

      serviceConfig = {
        Type = "simple";
        ExecStart = "${cfg.package}/bin/otd-daemon -c ${cfg.package}/lib/OpenTabletDriver/Configurations";
        Restart = "on-failure";
      };
    };
  };
}
{'fraction_non_alphanumeric': 0.10745927407830809, 'fraction_numerical': 0.0, 'mean_word_length': 2.141831238779174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3620459', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1007, 'n_words': 228}