mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 23:36:17 +01:00
47 lines
1 KiB
Nix
47 lines
1 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
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/
|
|
chmod 0700 /var/lib/sonarr/
|
|
'';
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = "sonarr";
|
|
Group = "sonarr";
|
|
PermissionsStartOnly = "true";
|
|
ExecStart = "${pkgs.sonarr}/bin/NzbDrone --no-browser";
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
|
|
users.users.sonarr = {
|
|
uid = config.ids.uids.sonarr;
|
|
home = "/var/lib/sonarr";
|
|
group = "sonarr";
|
|
};
|
|
users.groups.sonarr.gid = config.ids.gids.sonarr;
|
|
|
|
};
|
|
}
|