2022-10-02 17:40:10 +00:00
|
|
|
{ config, lib, ... }: {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
streamServer = lib.mkOption {
|
2023-01-21 14:29:03 +00:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2022-10-02 17:40:10 +00:00
|
|
|
description = "Hostname for Jellyfin library";
|
2022-12-21 21:18:03 +00:00
|
|
|
default = null;
|
2022-10-02 17:40:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-21 21:38:34 +00:00
|
|
|
config = lib.mkIf (config.streamServer != null) {
|
2022-10-02 17:40:10 +00:00
|
|
|
|
|
|
|
services.jellyfin.enable = true;
|
2023-04-16 20:33:16 +00:00
|
|
|
users.users.jellyfin = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "jellyfin";
|
|
|
|
};
|
2022-10-02 17:40:10 +00:00
|
|
|
|
2022-12-21 21:18:03 +00:00
|
|
|
caddy.routes = [{
|
2022-10-02 17:40:10 +00:00
|
|
|
match = [{ host = [ config.streamServer ]; }];
|
|
|
|
handle = [{
|
|
|
|
handler = "reverse_proxy";
|
|
|
|
upstreams = [{ dial = "localhost:8096"; }];
|
|
|
|
}];
|
|
|
|
}];
|
2022-10-04 22:59:28 +00:00
|
|
|
|
2023-02-28 04:27:10 +00:00
|
|
|
# Grant user access to Jellyfin directories
|
|
|
|
users.users.${config.user}.extraGroups = [ "jellyfin" ];
|
|
|
|
|
2022-10-04 22:59:28 +00:00
|
|
|
# Create videos directory, allow anyone in Jellyfin group to manage it
|
2022-10-23 04:16:42 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /var/lib/jellyfin 0775 jellyfin jellyfin"
|
|
|
|
"d /var/lib/jellyfin/library 0775 jellyfin jellyfin"
|
|
|
|
];
|
2022-10-04 22:59:28 +00:00
|
|
|
|
2022-10-02 17:40:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|