nixpkgs/nixos/modules/services/misc/sonarr.nix

48 lines
1.0 KiB
Nix
Raw Normal View History

2016-06-02 20:00:00 +01:00
{ config, pkgs, lib, mono, ... }:
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/
}
chown -R sonarr:sonarr /var/lib/sonarr/
2016-06-02 20:00:00 +01:00
chmod 0700 /var/lib/sonarr/
'';
serviceConfig = {
Type = "simple";
User = "sonarr";
Group = "sonarr";
2016-06-02 20:00:00 +01:00
PermissionsStartOnly = "true";
ExecStart = "${pkgs.sonarr}/bin/NzbDrone --no-browser";
Restart = "on-failure";
};
};
users.users.sonarr = {
uid = config.ids.uids.sonarr;
2016-06-02 20:00:00 +01:00
home = "/var/lib/sonarr";
group = "sonarr";
2016-06-02 20:00:00 +01:00
};
users.groups.sonarr.gid = config.ids.gids.sonarr;
2016-06-02 20:00:00 +01:00
};
}