1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/nixos/modules/services/misc/emby.nix

70 lines
1.5 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
2016-04-23 14:49:33 +01:00
with lib;
let
cfg = config.services.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.";
};
dataDir = mkOption {
type = types.path;
default = "/var/lib/emby/ProgramData-Server";
description = "Location where Emby stores its data.";
};
2016-04-23 14:49:33 +01:00
};
};
config = mkIf cfg.enable {
systemd.services.emby = {
description = "Emby Media Server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart = ''
test -d ${cfg.dataDir} || {
echo "Creating initial Emby data directory in ${cfg.dataDir}"
mkdir -p ${cfg.dataDir}
chown -R ${cfg.user}:${cfg.group} ${cfg.dataDir}
2016-04-23 14:49:33 +01:00
}
'';
serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
PermissionsStartOnly = "true";
ExecStart = "${pkgs.emby}/bin/MediaBrowser.Server.Mono";
2016-04-23 14:49:33 +01:00
Restart = "on-failure";
};
};
users.users = mkIf (cfg.user == "emby") {
2016-04-23 14:49:33 +01:00
emby = {
group = cfg.group;
uid = config.ids.uids.emby;
};
};
users.groups = mkIf (cfg.group == "emby") {
2016-04-23 14:49:33 +01:00
emby = {
gid = config.ids.gids.emby;
};
};
};
}