From bdb4cf6c59b262c39b77a1d296116817b7631b42 Mon Sep 17 00:00:00 2001
From: Mario Rodas <marsam@users.noreply.github.com>
Date: Mon, 13 May 2019 01:00:00 -0500
Subject: [PATCH] rtorrent: add module

---
 modules/modules.nix           |  1 +
 modules/programs/rtorrent.nix | 37 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 modules/programs/rtorrent.nix

diff --git a/modules/modules.nix b/modules/modules.nix
index f2f54f4e1..2dc89ebc0 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -84,6 +84,7 @@ let
     (loadModule ./programs/opam.nix { })
     (loadModule ./programs/pidgin.nix { })
     (loadModule ./programs/rofi.nix { })
+    (loadModule ./programs/rtorrent.nix { })
     (loadModule ./programs/skim.nix { })
     (loadModule ./programs/starship.nix { })
     (loadModule ./programs/ssh.nix { })
diff --git a/modules/programs/rtorrent.nix b/modules/programs/rtorrent.nix
new file mode 100644
index 000000000..6300969a5
--- /dev/null
+++ b/modules/programs/rtorrent.nix
@@ -0,0 +1,37 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.programs.rtorrent;
+
+in
+
+{
+  meta.maintainers = [ maintainers.marsam ];
+
+  options.programs.rtorrent = {
+    enable = mkEnableOption "rTorrent";
+
+    settings = mkOption {
+      type = types.lines;
+      default = "";
+      description = ''
+        Configuration written to
+        <filename>~/.config/rtorrent/rtorrent.rc</filename>. See
+        <link xlink:href="https://github.com/rakshasa/rtorrent/wiki/Config-Guide" />
+        for explanation about possible values.
+      '';
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+    home.packages = [ pkgs.rtorrent ];
+
+    xdg.configFile."rtorrent/rtorrent.rc" = mkIf (cfg.settings != "") {
+      text = cfg.settings;
+    };
+  };
+}