Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement aria2 service for controlling a daemon via rpc. #25181

Merged
merged 3 commits into from Apr 28, 2017

Conversation

indiscipline
Copy link
Contributor

@indiscipline indiscipline commented Apr 24, 2017

Motivation for this change

Implement aria2 systemd service for controlling a daemon instance via rpc. There's already a nix package for aria2, but no service unit. Aria2 can be controlled by a few freely-available web-uis via rpc calls.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@indiscipline, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ehmry, @edolstra and @joachifm to be potential reviewers.

@indiscipline
Copy link
Contributor Author

Ping @LnL7, @jgeerds, @rasendubi (previously merged aria2-related PRs).

Copy link
Member

@rasendubi rasendubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superficially looks good except some minor comments.

@@ -547,6 +548,7 @@
#rpc = 271; # unused
#geoip = 272; # unused
fcron = 273;
aria2 = 274;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

accessible to users in the "aria2" group.
'';
};
openPorts = mkOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Services should not open firewall ports. (The only exception is sshd.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my bad. Copied from some other service and did't give enough thought.

};
extraArguments = mkOption {
type = types.string;
example = "--rpc-secret=12345 --enable-rpc --rpc-listen-all";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rpc-secret already has an option and --enable-rpc is always added, so these should not go into extraArguments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


Targets are downloaded to ${downloadDir} by default and are
accessible to users in the "aria2" group.
'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual indentation pattern for multi-line strings is next:

{
  description = ''
    blah-blah
  '';
# ^ only two spaces here
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

wantedBy = [ "multi-user.target" ];
preStart = ''
mkdir -m 0770 -p "${homeDir}"
chown aria2:aria2 "${homeDir}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation seems to be broken in preStart.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
User = "aria2";
Group = "aria2";
PermissionsStartOnly = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@indiscipline
Copy link
Contributor Author

Is there anything else to be fixed before merge?

@rasendubi rasendubi merged commit a012b15 into NixOS:master Apr 28, 2017
@rasendubi
Copy link
Member

Thanks for the contribution!

@indiscipline
Copy link
Contributor Author

Thanks for the review, @rasendubi. All went pretty smooth for a first PR. I'll try better next time, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants