aria2: add module

PR #1202
This commit is contained in:
Justin Lovinger 2020-04-28 14:38:41 -04:00 committed by Robert Helgesson
parent ded327b9fc
commit 1dd226fde7
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 114 additions and 0 deletions

2
.github/CODEOWNERS vendored
View file

@ -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

View file

@ -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'
'';
}
];
};
}

View file

@ -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 { })

View file

@ -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 <filename>aria2.conf</filename> file.
See
<citerefentry>
<refentrytitle>aria2c</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
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 <filename>aria2.conf</filename> 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);
};
}

View file

@ -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

View file

@ -0,0 +1 @@
{ aria2-settings = ./settings.nix; }

View file

@ -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.
''
}
'';
};
}