about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorJoachim Fasting <joachifm@users.noreply.github.com>2016-04-23 18:09:32 +0200
committerJoachim Fasting <joachifm@users.noreply.github.com>2016-04-23 18:09:32 +0200
commit343f444dbaf6683b530e8efe4250a98c3b39ec29 (patch)
treed5bab4f21812dc136e8834a89e2e65bfbd8cc172 /nixos/modules
parentfc7c7d63326b17816ea07950476cb119a17392ba (diff)
parentc145f6eaa75567f87dd2f61832c3e28f067cfe2b (diff)
downloadnixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.tar
nixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.tar.gz
nixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.tar.bz2
nixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.tar.lz
nixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.tar.xz
nixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.tar.zst
nixlib-343f444dbaf6683b530e8efe4250a98c3b39ec29.zip
Merge pull request #14925 from mayflower/emby-upstream
emby: init at 3.0.5930
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/emby.nix64
3 files changed, 67 insertions, 0 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 9e6bbc744381..684ca132bc74 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -263,6 +263,7 @@
       caddy = 239;
       taskd = 240;
       factorio = 241;
+      emby = 242;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -497,6 +498,7 @@
       caddy = 239;
       taskd = 240;
       factorio = 241;
+      emby = 242;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 41210e648511..972802b2341f 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -216,6 +216,7 @@
   ./services/misc/dictd.nix
   ./services/misc/disnix.nix
   ./services/misc/docker-registry.nix
+  ./services/misc/emby.nix
   ./services/misc/etcd.nix
   ./services/misc/felix.nix
   ./services/misc/folding-at-home.nix
diff --git a/nixos/modules/services/misc/emby.nix b/nixos/modules/services/misc/emby.nix
new file mode 100644
index 000000000000..fe872349f45e
--- /dev/null
+++ b/nixos/modules/services/misc/emby.nix
@@ -0,0 +1,64 @@
+{ config, pkgs, lib, mono, ... }:
+
+with lib;
+
+let
+  cfg = config.services.emby;
+  emby = pkgs.emby;
+in
+{
+  options = {
+    services.emby = {
+      enable = mkEnableOption "Emby Media Server";
+
+      user = mkOption {
+        type = types.str;
+        default = "emby";
+        description = "User account under which Emby runs.";
+      };
+
+      group = mkOption {
+        type = types.str;
+        default = "emby";
+        description = "Group under which emby runs.";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.emby = {
+      description = "Emby Media Server";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      preStart = ''
+        test -d /var/lib/emby/ProgramData-Server || {
+          echo "Creating initial Emby data directory in /var/lib/emby/ProgramData-Server"
+          mkdir -p /var/lib/emby/ProgramData-Server
+          chown -R ${cfg.user}:${cfg.group} /var/lib/emby/ProgramData-Server
+          }
+      '';
+
+      serviceConfig = {
+        Type = "simple";
+        User = cfg.user;
+        Group = cfg.group;
+        PermissionsStartOnly = "true";
+        ExecStart = "${pkgs.mono}/bin/mono ${pkgs.emby}/bin/MediaBrowser.Server.Mono.exe";
+        Restart = "on-failure";
+      };
+    };
+
+    users.extraUsers = mkIf (cfg.user == "emby") {
+      emby = {
+        group = cfg.group;
+        uid = config.ids.uids.emby;
+      };
+    };
+
+    users.extraGroups = mkIf (cfg.group == "emby") {
+      emby = {
+        gid = config.ids.gids.emby;
+      };
+    };
+  };
+}