at master 1.2 kB view raw
1{ pkgs, ... }: 2let 3 rpcSecret = "supersecret"; 4 rpc-listen-port = 6800; 5 curlBody = { 6 jsonrpc = 2.0; 7 id = 1; 8 method = "aria2.getVersion"; 9 params = [ "token:${rpcSecret}" ]; 10 }; 11in 12{ 13 name = "aria2"; 14 15 nodes.machine = { 16 environment.etc."aria2Rpc".text = rpcSecret; 17 services.aria2 = { 18 enable = true; 19 rpcSecretFile = "/etc/aria2Rpc"; 20 settings = { 21 inherit rpc-listen-port; 22 allow-overwrite = false; 23 check-integrity = true; 24 console-log-level = "warn"; 25 listen-port = [ 26 { 27 from = 20000; 28 to = 20010; 29 } 30 { 31 from = 22222; 32 to = 22222; 33 } 34 ]; 35 max-concurrent-downloads = 50; 36 seed-ratio = 1.2; 37 summary-interval = 0; 38 }; 39 }; 40 }; 41 42 testScript = '' 43 machine.start() 44 machine.wait_for_unit("aria2.service") 45 curl_cmd = 'curl --fail-with-body -X POST -H "Content-Type: application/json" \ 46 -d \'${builtins.toJSON curlBody}\' http://localhost:${toString rpc-listen-port}/jsonrpc' 47 print(machine.wait_until_succeeds(curl_cmd, timeout=10)) 48 machine.shutdown() 49 ''; 50 51 meta.maintainers = [ pkgs.lib.maintainers.timhae ]; 52}