git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/bazarr: init
commit8724c96e718898d0913b3f2dce571f25eceeaacc authorDavid Terry <me@xwvvvvwx.com> dateSun 10 May 2020, 12:54 (7 years ago) parent81ccf13
4 files changed+104
nixos/modules/module-list.nix+1 nixos/modules/services/misc/bazarr.nix+76 nixos/tests/all-tests.nix+1 nixos/tests/bazarr.nix+26
nixos/modules/module-list.nix+1
@@ -415,6 +415,7 @@
415415 ./services/misc/apache-kafka.nix
416416 ./services/misc/autofs.nix
417417 ./services/misc/autorandr.nix
418+ ./services/misc/bazarr.nix
418419 ./services/misc/beanstalkd.nix
419420 ./services/misc/bees.nix
420421 ./services/misc/bepasty.nix
nixos/modules/services/misc/bazarr.nixnew file+76
@@ -0,0 +1,76 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.bazarr;
7+in
8+{
9+ options = {
10+ services.bazarr = {
11+ enable = mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";
12+
13+ openFirewall = mkOption {
14+ type = types.bool;
15+ default = false;
16+ description = "Open ports in the firewall for the bazarr web interface.";
17+ };
18+
19+ listenPort = mkOption {
20+ type = types.port;
21+ default = 6767;
22+ description = "Port on which the bazarr web interface should listen";
23+ };
24+
25+ user = mkOption {
26+ type = types.str;
27+ default = "bazarr";
28+ description = "User account under which bazarr runs.";
29+ };
30+
31+ group = mkOption {
32+ type = types.str;
33+ default = "bazarr";
34+ description = "Group under which bazarr runs.";
35+ };
36+ };
37+ };
38+
39+ config = mkIf cfg.enable {
40+ systemd.services.bazarr = {
41+ description = "bazarr";
42+ after = [ "network.target" ];
43+ wantedBy = [ "multi-user.target" ];
44+
45+ serviceConfig = rec {
46+ Type = "simple";
47+ User = cfg.user;
48+ Group = cfg.group;
49+ StateDirectory = "bazarr";
50+ SyslogIdentifier = "bazarr";
51+ ExecStart = pkgs.writeShellScript "start-bazarr" ''
52+ ${pkgs.bazarr}/bin/bazarr \
53+ --config '/var/lib/${StateDirectory}' \
54+ --port ${toString cfg.listenPort} \
55+ --no-update True
56+ '';
57+ Restart = "on-failure";
58+ };
59+ };
60+
61+ networking.firewall = mkIf cfg.openFirewall {
62+ allowedTCPPorts = [ cfg.listenPort ];
63+ };
64+
65+ users.users = mkIf (cfg.user == "bazarr") {
66+ bazarr = {
67+ group = cfg.group;
68+ home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
69+ };
70+ };
71+
72+ users.groups = mkIf (cfg.group == "bazarr") {
73+ bazarr = {};
74+ };
75+ };
76+}
nixos/tests/all-tests.nix+1
@@ -27,6 +27,7 @@ in
2727 atd = handleTest ./atd.nix {};
2828 avahi = handleTest ./avahi.nix {};
2929 babeld = handleTest ./babeld.nix {};
30+ bazarr = handleTest ./bazarr.nix {};
3031 bcachefs = handleTestOn ["x86_64-linux"] ./bcachefs.nix {}; # linux-4.18.2018.10.12 is unsupported on aarch64
3132 beanstalkd = handleTest ./beanstalkd.nix {};
3233 bees = handleTest ./bees.nix {};
nixos/tests/bazarr.nixnew file+26
@@ -0,0 +1,26 @@
1+import ./make-test-python.nix ({ lib, ... }:
2+
3+with lib;
4+
5+let
6+ port = 42069;
7+in
8+{
9+ name = "bazarr";
10+ meta.maintainers = with maintainers; [ xwvvvvwx ];
11+
12+ nodes.machine =
13+ { pkgs, ... }:
14+ {
15+ services.bazarr = {
16+ enable = true;
17+ listenPort = port;
18+ };
19+ };
20+
21+ testScript = ''
22+ machine.wait_for_unit("bazarr.service")
23+ machine.wait_for_open_port("${toString port}")
24+ machine.succeed("curl --fail http://localhost:${toString port}/")
25+ '';
26+})