summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2019-04-14 13:10:50 +0200
committerMinijackson <minijackson@riseup.net>2019-04-28 11:03:50 +0200
commiteb8dac2fcd80f1b79225d11dea5b44f678f5a00e (patch)
treec4e0702da60d6628afcdb99935c0c017735ac16b /nixos
parenta210440959209b14c8bc0ca965a03377ee7e8934 (diff)
downloadnixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.tar
nixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.tar.gz
nixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.tar.bz2
nixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.tar.lz
nixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.tar.xz
nixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.tar.zst
nixpkgs-eb8dac2fcd80f1b79225d11dea5b44f678f5a00e.zip
nixos/jellyfin: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/jellyfin.nix60
2 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index fca4a20eee6..56c44a43c6e 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -414,6 +414,7 @@
   ./services/misc/ihaskell.nix
   ./services/misc/irkerd.nix
   ./services/misc/jackett.nix
+  ./services/misc/jellyfin.nix
   ./services/misc/logkeys.nix
   ./services/misc/leaps.nix
   ./services/misc/lidarr.nix
diff --git a/nixos/modules/services/misc/jellyfin.nix b/nixos/modules/services/misc/jellyfin.nix
new file mode 100644
index 00000000000..7f38dd0ff23
--- /dev/null
+++ b/nixos/modules/services/misc/jellyfin.nix
@@ -0,0 +1,60 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+  cfg = config.services.jellyfin;
+in
+{
+  options = {
+    services.jellyfin = {
+      enable = mkEnableOption "Jellyfin Media Server";
+
+      user = mkOption {
+        type = types.str;
+        default = "jellyfin";
+        description = "User account under which Jellyfin runs.";
+      };
+
+      group = mkOption {
+        type = types.str;
+        default = "jellyfin";
+        description = "Group under which jellyfin runs.";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.jellyfin = {
+      description = "Jellyfin Media Server";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+
+      serviceConfig = rec {
+        User = cfg.user;
+        Group = cfg.group;
+        StateDirectory = "jellyfin";
+        CacheDirectory = "jellyfin";
+        ExecStart = "${pkgs.jellyfin}/bin/jellyfin --datadir '/var/lib/${StateDirectory}' --cachedir '/var/cache/${CacheDirectory}'";
+        Restart = "on-failure";
+      };
+    };
+
+    users.users = mkIf (cfg.user == "jellyfin") {
+      jellyfin.group = cfg.group;
+    };
+
+    users.groups = mkIf (cfg.group == "jellyfin") {
+      jellyfin = {};
+    };
+
+    assertions = [
+      {
+        assertion = !config.services.emby.enable;
+        message = "Emby and Jellyfin are incompatible, you cannot enable both";
+      }
+    ];
+  };
+
+  meta.maintainers = with lib.maintainers; [ minijackson ];
+}