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

nixos/rtorrent: add rtorrent tmux service (user and system) #30850

Closed
wants to merge 21 commits into from
Closed

nixos/rtorrent: add rtorrent tmux service (user and system) #30850

wants to merge 21 commits into from

Conversation

csingley
Copy link
Contributor

Motivation for this change

rtorrent systemd service units, started within a tmux session. Both a system service and a user service are provided, somewhat following the install/enable config syntax of the emacsd expression. Particularly handy to bring up rtorrent at boot time.

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
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 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.

Also improve variable naming/usage; comments
rtorrent dataDir now interpreted as rtorrent user $HOME, and created via
useradd to avoid ExecPreStart being run as root.
rtorrent dataDir now interpreted as rtorrent user $HOME, and created via
useradd to avoid ExecPreStart being run as root.
@adisbladis
Copy link
Member

This PR should not contain commits from #30144 .
A lot of these commits should get squashed, I can't see a reason why this should be more than one commit.

@adisbladis adisbladis mentioned this pull request Oct 27, 2017
8 tasks
default = false;
description = ''
Whether to install a user service for rtorrent (via tmux).
The service must be manually started for each user with
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate text.

User = cfg.user;
Group = cfg.group;
ExecStart = "${pkgs.tmux}/bin/tmux new-session -c ${cfg.dataDir} -s rtorrent -n rtorrent -d rtorrent -n -o import=${cfg.configFile}";
ExecStop = "${pkgs.bash}/bin/bash -c \"tmux send-keys -t rtorrent C-q && while pidof rtorrent > /dev/null; do sleep 0.5; done\"";
Copy link
Member

Choose a reason for hiding this comment

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

This looks very hacky. Not sure if there is a better way to solve this together with tmux but it doesn't feel right to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's a little reminiscent of creaky init scripts.
On the plus side, it's at least a fairly well tested hack; lots of people have been using it on Arch for a few years:

https://wiki.archlinux.org/index.php/RTorrent#Systemd_services_using_tmux_or_screen

@csingley
Copy link
Contributor Author

Looks like the rtorrent devs have merged a patch to run rtorrent as a headless daemon, accessible only via XML-RPC not CLI:

rakshasa/rtorrent#446

This would be a better candidate, allowing systemd to manage the service directly and saving all this jiggery-pokery of operating through tmux. I'll withdraw the PR and wait for the release of 0.9.7.

@csingley csingley closed this Oct 27, 2017
@iv-nn iv-nn mentioned this pull request Mar 24, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants