aria2: add systemd service
This commit is contained in:
parent
41e6e2ab37
commit
eb6f347055
3 changed files with 48 additions and 0 deletions
|
|
@ -44,6 +44,8 @@ in
|
|||
}
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.enable = lib.mkEnableOption "Aria2 systemd integration";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
|
@ -52,5 +54,22 @@ in
|
|||
xdg.configFile."aria2/aria2.conf" = lib.mkIf (cfg.settings != { }) {
|
||||
source = keyValueFormat.generate "aria2.conf" cfg.settings;
|
||||
};
|
||||
|
||||
systemd.user.services.aria2 = lib.mkIf cfg.systemd.enable {
|
||||
Unit = {
|
||||
Description = "Aria2c daemon";
|
||||
Documentation = "man:aria2c(1)";
|
||||
X-Restart-Triggers = lib.mkIf (cfg.settings != { }) [
|
||||
"${config.xdg.configFile."aria2/aria2.conf".source}"
|
||||
];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${lib.getExe cfg.package} --enable-rpc";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{ lib, pkgs, ... }:
|
||||
{
|
||||
aria2-disabled = ./disabled.nix;
|
||||
aria2-settings = ./settings.nix;
|
||||
}
|
||||
// lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
aria2-systemd = ./systemd.nix;
|
||||
}
|
||||
|
|
|
|||
25
tests/modules/programs/aria2/systemd.nix
Normal file
25
tests/modules/programs/aria2/systemd.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
programs.aria2 = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@aria2@"; };
|
||||
systemd.enable = true;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/aria2.service \
|
||||
${builtins.toFile "aria2.service" ''
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@aria2@/bin/dummy --enable-rpc
|
||||
Restart=on-failure
|
||||
|
||||
[Unit]
|
||||
Description=Aria2c daemon
|
||||
Documentation=man:aria2c(1)
|
||||
''}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue