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

with lib;

let
  cfg = config.services.deluge;
  cfg_web = config.services.deluge.web;
in {
  options = {
    services.deluge = {
      enable = mkOption {
        default = false;
        example = true;
        description = ''
          Start Deluge daemon.
        ''; 
      };  
    };

    services.deluge.web = {
      enable = mkOption {
        default = false;
        example = true;
        description = ''
          Start Deluge Web daemon.
        ''; 
      };  
    };
  };

  config = mkIf cfg.enable {

    systemd.services.deluged = {
      after = [ "network.target" ];
      description = "Deluge BitTorrent Daemon";
      wantedBy = [ "multi-user.target" ];
      path = [ pkgs.pythonPackages.deluge ];
      serviceConfig.ExecStart = "${pkgs.pythonPackages.deluge}/bin/deluged -d";
      # To prevent "Quit & shutdown daemon" from working; we want systemd to manage it!
      serviceConfig.Restart = "on-success";
      serviceConfig.User = "deluge";
      serviceConfig.Group = "deluge";
    };
<commit_msg>deluge module: support specifying open file limit<commit_after>{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.deluge;
  cfg_web = config.services.deluge.web;
  openFilesLimit = 4096;

in {
  options = {
    services = {
      deluge = {
        enable = mkOption {
          default = false;
          example = true;
          description = "Start the Deluge daemon";
        };

        openFilesLimit = mkOption {
          default = openFilesLimit;
          example = 8192;
          description = ''
            Number of files to allow deluged to open.
          '';
        };
      };

      deluge.web = {
        enable = mkOption {
          default = false;
          example = true;
          description = ''
            Start Deluge Web daemon.
          '';
        };
      };
    };
  };

  config = mkIf cfg.enable {

    systemd.services.deluged = {
      after = [ "network.target" ];
      description = "Deluge BitTorrent Daemon";
      wantedBy = [ "multi-user.target" ];
      path = [ pkgs.pythonPackages.deluge ];
      serviceConfig = {
        ExecStart = "${pkgs.pythonPackages.deluge}/bin/deluged -d";
        # To prevent "Quit & shutdown daemon" from working; we want systemd to manage it!
        Restart = "on-success";
        User = "deluge";
        Group = "deluge";
        LimitNOFILE = cfg.openFilesLimit;
      };
    };

{'fraction_non_alphanumeric': 0.11936662606577345, 'fraction_numerical': 0.0032480714575720666, 'mean_word_length': 1.806378132118451, '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': '3820292', 'n_tokens_mistral': 760, 'n_tokens_neox': 739, 'n_words': 172}