summaryrefslogtreecommitdiffstats
path: root/makefu/3modules
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-08-21 13:16:56 +0200
committerlassulus <lass@aidsballs.de>2016-08-21 13:16:56 +0200
commitd50198d880c4be21413f9bb536b784005204beb9 (patch)
tree28ea56d3694e7239e532474f677a95f6604c00c5 /makefu/3modules
parent3eb5f58a0ee9778006d4e37fee17e0b3e096a52a (diff)
parentd1c4d12cee228cba1da4da7bba82b6cf6cb708ec (diff)
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/3modules')
-rw-r--r--makefu/3modules/default.nix3
-rw-r--r--makefu/3modules/deluge.nix185
-rw-r--r--makefu/3modules/populate.nix5
-rw-r--r--makefu/3modules/udpt.nix57
4 files changed, 250 insertions, 0 deletions
diff --git a/makefu/3modules/default.nix b/makefu/3modules/default.nix
index 7fc095ba..031ef1bc 100644
--- a/makefu/3modules/default.nix
+++ b/makefu/3modules/default.nix
@@ -2,11 +2,14 @@ _:
{
imports = [
+ ./populate.nix
./awesome-extra.nix
+ ./deluge.nix
./forward-journal.nix
./ps3netsrv.nix
./snapraid.nix
./taskserver.nix
+ ./udpt.nix
./umts.nix
];
}
diff --git a/makefu/3modules/deluge.nix b/makefu/3modules/deluge.nix
new file mode 100644
index 00000000..e81f96f8
--- /dev/null
+++ b/makefu/3modules/deluge.nix
@@ -0,0 +1,185 @@
+{ config, lib, pkgs, ... }:
+# based on <nixpkgs>/nixos/modules/services/torrent/deluge.nix
+with config.krebs.lib;
+
+let
+ cfg_daemon = config.makefu.deluge;
+ homedir = cfg_daemon.homedir;
+ delugedir = "${homedir}/.config/deluge";
+ cfg_web = config.makefu.deluge.web;
+ core_conf = pkgs.writeText "deluge-core-cfg" ''
+ {
+ "file": 1,
+ "format": 1
+ }${builtins.toJSON (default_core_cfg // cfg_daemon.cfg)}
+ '';
+
+ default_core_cfg = {
+ # ports and networking
+ daemon_port = 58846; allow_remote = false;
+ listen_ports = [ 0 0 ]; # from -> to, 0 -> random
+ outgoing_ports = [ 0 0 ];
+ random_port = true;
+ random_outgoing_ports = true;
+ listen_interface = "";
+ # folders
+ move_completed_path = homedir +"/complete"; move_completed = false;
+ autoadd_location = homedir + "/watch"; autoadd_enable = true;
+ download_location = homedir + "/data";
+ torrentfiles_location = homedir + "/torrents"; copy_torrent_file = false; del_copy_torrent_file = false;
+ plugins_location = homedir + "/.config/deluge/plugins"; enabled_plugins = [];
+ geoip_db_location = pkgs.geolite-legacy + "/share/GeoIP/GeoIP.dat";
+ queue_new_to_top = false;
+ info_sent = 0;
+ send_info = false;
+ compact_allocation = false;
+ # peer discovery, extras
+ lsd = true;
+ natpmp = true;
+ utpex = false;
+ dht = false;
+ upnp = true;
+ peer_tos = "0x08";
+ # active torrents
+ dont_count_slow_torrents = false;
+ max_active_limit = -1;
+ max_active_downloading = -1;
+ max_active_seeding = -1;
+ max_upload_slots_global = -1;
+ # seeding
+ share_ratio_limit = -1;
+ seed_time_ratio_limit = -1;
+ seed_time_limit = 180;
+ stop_seed_at_ratio = false;
+ remove_seed_at_ratio = false;
+ stop_seed_ratio = 2;
+ # speed and connections
+ rate_limit_ip_overhead = true;
+ ignore_limits_on_local_network = true;
+ max_download_speed = -1;
+ max_upload_speed = -1;
+ max_upload_speed_per_torrent = -1;
+ max_download_speed_per_torrent = -1;
+ max_half_open_connections = -1;
+ max_connections_global = -1;
+ max_connections_per_second = -1;
+ max_connections_per_torrent = -1;
+ max_upload_slots_per_torrent = -1;
+ enc_in_policy = 1;
+ enc_prefer_rc4 = true;
+ enc_level = 2;
+ enc_out_policy = 1;
+ cache_size = 8192;
+ cache_expiry = 60;
+ prioritize_first_last_pieces = false;
+ auto_managed = true;
+ proxies = {
+ peer = {
+ username = "";
+ password = "";
+ hostname = "";
+ type = 0;
+ port = 8080;
+ };
+ web_seed = {
+ username = "";
+ password = "";
+ hostname = "";
+ type = 0;
+ port = 8080;
+ };
+ tracker = {
+ username = "";
+ password = "";
+ hostname = "";
+ type = 0;
+ port = 8080;
+ };
+ dht = {
+ username = "";
+ password = "";
+ hostname = "";
+ type = 0;
+ port = 8080;
+ };
+ };
+ add_paused = false;
+ new_release_check = false;
+ };
+
+ api = {
+ enable = mkEnableOption "deluge daemon";
+
+ cfg = mkOption {
+ default = default_core_cfg;
+ type = types.attrsOf types.unspecified;
+ description = ''
+ for full configuration see defaults
+ '';
+ example = {
+ "daemon_port"= 58846;
+ "download_location"= "/var/download";
+ };
+ };
+
+ auth = mkOption {
+ default = [];
+ example = ["alice:MyC0mpL3xPass:10"];
+ type = types.lines;
+ };
+
+ homedir = mkOption {
+ default = "/var/lib/deluge";
+ description = "Home directory of deluge user";
+ type = types.str;
+ };
+
+ web = {
+ enable = mkEnableOption "deluge web";
+ };
+ };
+ imp = {
+
+ systemd.services.deluged = {
+ after = [ "network.target" ];
+ description = "Deluge BitTorrent Daemon";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ ExecStart = "${pkgs.pythonPackages.deluge}/bin/deluged -d";
+ ExecStartPre = let
+ in pkgs.writeDash "deluged-init" ''
+ mkdir -p ${delugedir}
+ echo ${shell.escape cfg_daemon.auth} > ${delugedir}/auth
+ cp -f ${core_conf} ${delugedir}/core.conf
+ '';
+ Restart = "on-success";
+ User = "deluge";
+ Group = "deluge";
+ };
+ };
+
+ systemd.services.delugeweb = mkIf cfg_web.enable {
+ after = [ "network.target" ];
+ description = "Deluge BitTorrent WebUI";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig.ExecStart = "${pkgs.pythonPackages.deluge}/bin/deluge --ui web";
+ serviceConfig.User = "deluge";
+ serviceConfig.Group = "deluge";
+ };
+
+ environment.systemPackages = [ pkgs.pythonPackages.deluge ];
+
+ users.extraUsers.deluge = {
+ group = "deluge";
+ uid = config.ids.uids.deluge;
+ home = cfg_daemon.homedir;
+ createHome = true;
+ description = "Deluge Daemon user";
+ };
+
+ users.extraGroups.deluge.gid = config.ids.gids.deluge;
+ };
+in {
+ options.makefu.deluge = api;
+ config = lib.mkIf cfg_daemon.enable imp;
+}
diff --git a/makefu/3modules/populate.nix b/makefu/3modules/populate.nix
new file mode 100644
index 00000000..19d3b369
--- /dev/null
+++ b/makefu/3modules/populate.nix
@@ -0,0 +1,5 @@
+{config, lib, pkgs, ... }:
+
+{
+ options.makefu.full-populate = lib.mkEnableOption "always do a full clone of nixpkgs";
+}
diff --git a/makefu/3modules/udpt.nix b/makefu/3modules/udpt.nix
new file mode 100644
index 00000000..2086bd54
--- /dev/null
+++ b/makefu/3modules/udpt.nix
@@ -0,0 +1,57 @@
+{ config, lib, pkgs, ... }:
+
+with config.krebs.lib;
+let
+ cfg = config.makefu.udpt;
+
+ out = {
+ options.makefu.udpt = api;
+ config = lib.mkIf cfg.enable imp;
+ };
+
+ api = {
+ enable = mkEnableOption "udpt";
+
+ package = mkOption {
+ type = types.package;
+ default = pkgs.udpt;
+ };
+
+ cfgfile = mkOption {
+ type = types.path;
+ default = "${cfg.package}/etc/udpt.conf";
+ };
+
+ user = mkOption {
+ description = ''
+ user which will run udpt. if kept default a new user will be created
+ '';
+ type = types.str;
+ default = "udpt";
+ };
+
+ };
+
+ imp = {
+ systemd.services.udpt = {
+ description = "udpt server";
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ restartIfChanged = true;
+ serviceConfig = {
+ Type = "simple";
+ ExecStart = "${cfg.package}/bin/udpt -c ${shell.escape cfg.cfgfile}";
+ PrivateTmp = true;
+ User = "${cfg.user}";
+ };
+ };
+ users = lib.mkIf (cfg.user == "udpt") {
+ users.udpt = {
+ uid = genid "udpt";
+ };
+ groups.udpt.gid = genid "udpt";
+ };
+ };
+in
+out
+