diff options
author | Tristan Helmich <tristan.helmich@gmail.com> | 2016-04-23 15:49:33 +0200 |
---|---|---|
committer | Tristan Helmich <tristan.helmich@gmail.com> | 2016-04-23 16:13:53 +0200 |
commit | c145f6eaa75567f87dd2f61832c3e28f067cfe2b (patch) | |
tree | bd561c08782e672453932bc5d99e12ddb4e23eb7 /nixos/modules/services/misc/emby.nix | |
parent | dd16ab92dc7f11c83d74c58f8eb94c7d40191623 (diff) | |
download | nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.tar nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.tar.gz nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.tar.bz2 nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.tar.lz nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.tar.xz nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.tar.zst nixlib-c145f6eaa75567f87dd2f61832c3e28f067cfe2b.zip |
emby service: new service
Diffstat (limited to 'nixos/modules/services/misc/emby.nix')
-rw-r--r-- | nixos/modules/services/misc/emby.nix | 64 |
1 files changed, 64 insertions, 0 deletions
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; + }; + }; + }; +} |