summary refs log tree commit diff
path: root/nixos/modules/services/misc/sonarr.nix
diff options
context:
space:
mode:
authorTristan Helmich <tristan.helmich@gmail.com>2016-06-02 21:00:00 +0200
committerTristan Helmich <tristan.helmich@gmail.com>2016-07-15 16:18:37 +0200
commited466b7fef35e7e6ce4eeb80075e9b76151ff029 (patch)
treec9150f2019980b5ec190d09129b2b140dee51456 /nixos/modules/services/misc/sonarr.nix
parenta66400631474d87a57478e91808ef156f82d0813 (diff)
downloadnixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.tar
nixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.tar.gz
nixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.tar.bz2
nixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.tar.lz
nixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.tar.xz
nixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.tar.zst
nixpkgs-ed466b7fef35e7e6ce4eeb80075e9b76151ff029.zip
sonarr service: initial service
Diffstat (limited to 'nixos/modules/services/misc/sonarr.nix')
-rw-r--r--nixos/modules/services/misc/sonarr.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/sonarr.nix b/nixos/modules/services/misc/sonarr.nix
new file mode 100644
index 00000000000..6d96daa6c3d
--- /dev/null
+++ b/nixos/modules/services/misc/sonarr.nix
@@ -0,0 +1,44 @@
+{ 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 /var/lib/sonarr/
+        chmod 0700 /var/lib/sonarr/
+      '';
+
+      serviceConfig = {
+        Type = "simple";
+        User = "sonarr";
+        Group = "nogroup";
+        PermissionsStartOnly = "true";
+        ExecStart = "${pkgs.sonarr}/bin/NzbDrone --no-browser";
+        Restart = "on-failure";
+      };
+    };
+
+    users.extraUsers.sonarr = {
+      home = "/var/lib/sonarr";
+    };
+
+  };
+}