diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 98d2957ab..b31ef883c 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -22,6 +22,8 @@
/modules/misc/xdg-user-dirs.nix @pacien
+/modules/programs/aria2.nix @JustinLovinger
+
/modules/programs/autorandr.nix @uvNikita
/modules/programs/bash.nix @rycee
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 2be9b701c..9cfdb572e 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1496,6 +1496,13 @@ in
A new module is available: 'programs.i3status'
'';
}
+
+ {
+ time = "2020-05-03T11:21:42+00:00";
+ message = ''
+ A new module is available: 'programs.aria2'
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index f01975e91..ae114857a 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -45,6 +45,7 @@ let
(loadModule ./programs/afew.nix { })
(loadModule ./programs/alacritty.nix { })
(loadModule ./programs/alot.nix { })
+ (loadModule ./programs/aria2.nix { })
(loadModule ./programs/astroid.nix { })
(loadModule ./programs/autorandr.nix { })
(loadModule ./programs/bash.nix { })
diff --git a/modules/programs/aria2.nix b/modules/programs/aria2.nix
new file mode 100644
index 000000000..d1317ff76
--- /dev/null
+++ b/modules/programs/aria2.nix
@@ -0,0 +1,61 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.programs.aria2;
+
+ formatLine = n: v:
+ let
+ formatValue = v:
+ if builtins.isBool v then
+ (if v then "true" else "false")
+ else
+ toString v;
+ in "${n}=${formatValue v}";
+in {
+ meta.maintainers = [ hm.maintainers.justinlovinger ];
+
+ options.programs.aria2 = {
+ enable = mkEnableOption "aria2";
+
+ settings = mkOption {
+ type = with types; attrsOf (oneOf [ bool float int str ]);
+ default = { };
+ description = ''
+ Options to add to aria2.conf file.
+ See
+
+ aria2c
+ 1
+
+ for options.
+ '';
+ example = literalExample ''
+ {
+ listen-port = 60000;
+ dht-listen-port = 60000;
+ seed-ratio = 1.0;
+ max-upload-limit = "50K";
+ ftp-pasv = true;
+ }
+ '';
+ };
+
+ extraConfig = mkOption {
+ type = types.lines;
+ default = "";
+ description = ''
+ Extra lines added to aria2.conf file.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = [ pkgs.aria2 ];
+
+ xdg.configFile."aria2/aria2.conf".text = concatStringsSep "\n" ([ ]
+ ++ mapAttrsToList formatLine cfg.settings
+ ++ optional (cfg.extraConfig != "") cfg.extraConfig);
+ };
+}
diff --git a/tests/default.nix b/tests/default.nix
index c6dcecbea..f63f8f0cf 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -36,6 +36,7 @@ import nmt {
./modules/misc/fontconfig
./modules/programs/alacritty
./modules/programs/alot
+ ./modules/programs/aria2
./modules/programs/bash
./modules/programs/browserpass
./modules/programs/fish
diff --git a/tests/modules/programs/aria2/default.nix b/tests/modules/programs/aria2/default.nix
new file mode 100644
index 000000000..2964841d0
--- /dev/null
+++ b/tests/modules/programs/aria2/default.nix
@@ -0,0 +1 @@
+{ aria2-settings = ./settings.nix; }
diff --git a/tests/modules/programs/aria2/settings.nix b/tests/modules/programs/aria2/settings.nix
new file mode 100644
index 000000000..0b5a52d90
--- /dev/null
+++ b/tests/modules/programs/aria2/settings.nix
@@ -0,0 +1,41 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = {
+ programs.aria2 = {
+ enable = true;
+
+ settings = {
+ listen-port = 60000;
+ dht-listen-port = 60000;
+ seed-ratio = 1.0;
+ max-upload-limit = "50K";
+ ftp-pasv = true;
+ };
+
+ extraConfig = ''
+ # Extra aria2 configuration.
+ '';
+ };
+
+ nixpkgs.overlays =
+ [ (self: super: { aria2 = pkgs.writeScriptBin "dummy-aria2" ""; }) ];
+
+ nmt.script = ''
+ assertFileContent \
+ home-files/.config/aria2/aria2.conf \
+ ${
+ pkgs.writeText "aria2-expected-config.conf" ''
+ dht-listen-port=60000
+ ftp-pasv=true
+ listen-port=60000
+ max-upload-limit=50K
+ seed-ratio=1.000000
+ # Extra aria2 configuration.
+ ''
+ }
+ '';
+ };
+}