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

48 lines
1.0 KiB
Nix
Raw Normal View History

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