-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Conversation
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.
This PR should not contain commits from #30144 . |
default = false; | ||
description = '' | ||
Whether to install a user service for rtorrent (via tmux). | ||
The service must be manually started for each user with |
There was a problem hiding this comment.
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\""; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Looks like the rtorrent devs have merged a patch to run rtorrent as a headless daemon, accessible only via XML-RPC not CLI: 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. |
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
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)