summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorDavid Terry <me@xwvvvvwx.com>2020-05-10 12:54:09 +0200
committerBjørn Forsman <bjorn.forsman@gmail.com>2020-05-22 11:23:31 +0200
commit8724c96e718898d0913b3f2dce571f25eceeaacc (patch)
tree4fb8a3d8660ac7f31bd155e7faa28ef30638995e /nixos/modules
parent81ccf1303b0930d1d50239ad71bbe109fba9e18b (diff)
downloadnixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.tar
nixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.tar.gz
nixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.tar.bz2
nixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.tar.lz
nixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.tar.xz
nixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.tar.zst
nixpkgs-8724c96e718898d0913b3f2dce571f25eceeaacc.zip
nixos/bazarr: init
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/bazarr.nix76
2 files changed, 77 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 460c74f857c..d5285cfabd7 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -415,6 +415,7 @@
   ./services/misc/apache-kafka.nix
   ./services/misc/autofs.nix
   ./services/misc/autorandr.nix
+  ./services/misc/bazarr.nix
   ./services/misc/beanstalkd.nix
   ./services/misc/bees.nix
   ./services/misc/bepasty.nix
diff --git a/nixos/modules/services/misc/bazarr.nix b/nixos/modules/services/misc/bazarr.nix
new file mode 100644
index 00000000000..d3fd5b08cc8
--- /dev/null
+++ b/nixos/modules/services/misc/bazarr.nix
@@ -0,0 +1,76 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+  cfg = config.services.bazarr;
+in
+{
+  options = {
+    services.bazarr = {
+      enable = mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";
+
+      openFirewall = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Open ports in the firewall for the bazarr web interface.";
+      };
+
+      listenPort = mkOption {
+        type = types.port;
+        default = 6767;
+        description = "Port on which the bazarr web interface should listen";
+      };
+
+      user = mkOption {
+        type = types.str;
+        default = "bazarr";
+        description = "User account under which bazarr runs.";
+      };
+
+      group = mkOption {
+        type = types.str;
+        default = "bazarr";
+        description = "Group under which bazarr runs.";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.bazarr = {
+      description = "bazarr";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+
+      serviceConfig = rec {
+        Type = "simple";
+        User = cfg.user;
+        Group = cfg.group;
+        StateDirectory = "bazarr";
+        SyslogIdentifier = "bazarr";
+        ExecStart = pkgs.writeShellScript "start-bazarr" ''
+          ${pkgs.bazarr}/bin/bazarr \
+            --config '/var/lib/${StateDirectory}' \
+            --port ${toString cfg.listenPort} \
+            --no-update True
+        '';
+        Restart = "on-failure";
+      };
+    };
+
+    networking.firewall = mkIf cfg.openFirewall {
+      allowedTCPPorts = [ cfg.listenPort ];
+    };
+
+    users.users = mkIf (cfg.user == "bazarr") {
+      bazarr = {
+        group = cfg.group;
+        home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
+      };
+    };
+
+    users.groups = mkIf (cfg.group == "bazarr") {
+      bazarr = {};
+    };
+  };
+}