2018-07-20 22:56:59 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2016-06-02 21:00:00 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.sonarr;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.sonarr = {
|
|
|
|
enable = mkEnableOption "Sonarr";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.sonarr = {
|
|
|
|
description = "Sonarr";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
preStart = ''
|
|
|
|
test -d /var/lib/sonarr/ || {
|
|
|
|
echo "Creating sonarr data directory in /var/lib/sonarr/"
|
|
|
|
mkdir -p /var/lib/sonarr/
|
|
|
|
}
|
2017-04-22 09:44:12 +02:00
|
|
|
chown -R sonarr:sonarr /var/lib/sonarr/
|
2016-06-02 21:00:00 +02:00
|
|
|
chmod 0700 /var/lib/sonarr/
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
User = "sonarr";
|
2017-04-22 09:44:12 +02:00
|
|
|
Group = "sonarr";
|
2016-06-02 21:00:00 +02:00
|
|
|
PermissionsStartOnly = "true";
|
|
|
|
ExecStart = "${pkgs.sonarr}/bin/NzbDrone --no-browser";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.sonarr = {
|
2017-04-22 09:44:12 +02:00
|
|
|
uid = config.ids.uids.sonarr;
|
2016-06-02 21:00:00 +02:00
|
|
|
home = "/var/lib/sonarr";
|
2017-04-22 09:44:12 +02:00
|
|
|
group = "sonarr";
|
2016-06-02 21:00:00 +02:00
|
|
|
};
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.sonarr.gid = config.ids.gids.sonarr;
|
2016-06-02 21:00:00 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|