summaryrefslogtreecommitdiffstats
path: root/lass/3modules/pyload.nix
blob: 6f29ffb172d741c59f9ef0a39354be31e90ac845 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ config, lib, pkgs, ... }:

with import <stockholm/lib>;

let
  cfg = config.lass.pyload;

  out = {
    options.lass.pyload = api;
    config = lib.mkIf cfg.enable imp;
  };

  api = {
    enable = mkEnableOption "pyload";
    user = mkOption {
      type = types.str;
      default = "download";
    };
  };

  imp = {

    krebs.per-user.${cfg.user}.packages = [
      pkgs.pyload
      pkgs.spidermonkey
      pkgs.tesseract
    ];

    krebs.iptables.tables.filter.INPUT.rules = [
       { predicate = "-p tcp --dport 9099"; target = "ACCEPT"; }
    ];
    systemd.services.pyload = {
      description = "pyload";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];

      path = with pkgs; [
        pyload
        spidermonkey
        tesseract
        dnsmasq
      ];

      restartIfChanged = true;

      serviceConfig = {
        Restart = "always";
        ExecStart = "${pkgs.pyload}/bin/pyLoadCore";
        User = cfg.user;
      };
    };

  };

in out