fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6cfg = config . programs . aria2 ; 7 8formatLine = n :v : 9let 10formatValue = v : 11if builtins . isBool v then 12( if v then "true" else "false" ) 13else 14toString v ; 15in " ${ n } = ${ formatValue v } " ; 16in { 17meta . maintainers = [ hm . maintainers . justinlovinger ]; 18 19options . programs . aria2 = { 20enable = mkEnableOption "aria2" ; 21 22settings = mkOption { 23type = with types ; attrsOf ( oneOf [ bool float int str ]); 24default = { }; 25description = '' 26Options to add to {file}`aria2.conf` file. 27See 28{manpage}`aria2c(1)` 29for options. 30'' ; 31example = literalExpression '' 32{ 33listen-port = 60000; 34dht-listen-port = 60000; 35seed-ratio = 1.0; 36max-upload-limit = "50K"; 37ftp-pasv = true; 38} 39'' ; 40}; 41 42extraConfig = mkOption { 43type = types . lines ; 44default = "" ; 45description = '' 46Extra lines added to {file}`aria2.conf` file. 47'' ; 48}; 49}; 50 51config = mkIf cfg . enable { 52home . packages = [ pkgs . aria2 ]; 53 54xdg . configFile . "aria2/aria2.conf" . text = concatStringsSep "\n" ([ ] 55++ mapAttrsToList formatLine cfg . settings 56++ optional ( cfg . extraConfig != "" ) cfg . extraConfig ); 57}; 58}