Skip to content

feat: Add Jellystat configuration module#137

Closed
Darkatek7 wants to merge 9 commits into
kiriwalawren:mainfrom
Darkatek7:main
Closed

feat: Add Jellystat configuration module#137
Darkatek7 wants to merge 9 commits into
kiriwalawren:mainfrom
Darkatek7:main

Conversation

@Darkatek7

@Darkatek7 Darkatek7 commented Mar 20, 2026

Copy link
Copy Markdown

Summary

Resolves #61
Adds Jellystat statistics dashboard configuration module to nixflix.

Features

  • Enable via nixflix.jellystat.enable = true
  • Configurable port (default 3000), timezone, subdomain
  • Jellyfin URL and API key configuration
  • VPN routing support (Mullvad integration)
  • Nginx reverse proxy integration
  • Firewall configuration option

Usage Example

nixflix.jellystat = {
  enable = true;
  timezone = "Europe/Vienna";
  port = 3000;
  subdomain = "jellystat";
  jellyfin = {
    url = "http://jellyfin:8096";
    apiKey = "your-jellyfin-api-key";
  };
};

Files Changed

  • modules/default.nix - Added jellystat import
  • modules/globals.nix - Added jellystat UID/GID
  • modules/jellystat/default.nix - New module implementation

Comment thread modules/jellystat/default.nix Outdated

@kiriwalawren kiriwalawren left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First off, thank you so much for the PR. I greatly appreciate it.

I have a lot of comments.

This is my first time looking into Jellystat properly. And I have a couple of concerns. It seems to me like they really expect you to go through a setup wizard and don't have a lot of support for an automated workflow. Based on what I am seeing in the README. I don't see jellyfin integration in there, which implies it is only supported through UI (I hope this is wrong, please let me know if so). Even their JS_USER and JS_PASSWORD variables say "Master Override User in case username or password used during setup is forgotten". Which tells me that they aren't really expecting users to use those variables as their "only" method of configuration.

It seems like they have an API. So, hopefully we can just figure it out that way. Push comes to shove, we can look at the API calls of the setup wizard, and make a systemd service that replicates it. I had to do something similar for Jellyfin.

Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
@kiriwalawren kiriwalawren marked this pull request as draft March 20, 2026 09:37
@kiriwalawren

Copy link
Copy Markdown
Owner

When we get closer to feeling great about the implementation, we will also need to add tests and update the documentation.

I will help you figure those out when we get closer to it.

- Add auto-generated POSTGRES_PASSWORD and JWT_SECRET if not provided
- Add jellystat-setup-db service to configure PostgreSQL password
- Change jellyfin dependency to jellyfin-setup-wizard.service
- Add NS_USER/NS_PASSWORD options for master override
- Add configurable timezone option (defaults to time.timeZone)
- Fix wait-for-db to use TCP/IP instead of Unix socket
- Fix database name default to "jfstat" (matches Jellystat)
- Fix description punctuation per PR review
- Always set EnvironmentFile when service is enabled
@Darkatek7

Copy link
Copy Markdown
Author

Thanks for the detailed review! I've addressed all the feedback. Here's a summary of the changes:

All Comments Addressed

Description fixes: All option descriptions now properly end with periods.

Timezone option: Added timezone option that defaults to config.time.timeZone or "UTC" (thanks @takac for the suggestion).

Jellyfin URL: Redesigned to use jellyfin.hostname, jellyfin.port, jellyfin.useSsl, and jellyfin.urlBase to construct the URL automatically with sensible defaults.

API Key: Already uses mkSecretOption. The module auto-detects the Jellyfin API key from nixflix.jellyfin.config.apiKey when available.

VPN description: Fixed markdown formatting with proper line breaks between sentences.

Jellyfin dependency: Changed from jellyfin.service to jellyfin-setup-wizard.service to ensure Jellyfin is fully configured before Jellystat starts.

Environment variables: Added full support for:

  • POSTGRES_PASSWORD (auto-generated if not provided)
  • JWT_SECRET (auto-generated if not provided)
  • NS_USER and NS_PASSWORD via jellyfin.masterOverrideUser and jellyfin.masterOverridePassword
  • Added jellystat-setup-db.service to configure the PostgreSQL password before Jellystat connects

wait-for-db: Fixed to use TCP/IP connection (-h 127.0.0.1) instead of Unix socket, matching how Jellystat actually connects.

Database name: Changed default from "jellystat" to "jfstat" to match Jellystat's Docker default.

The commit is 67dd198 on the feat/jellystat branch in my fork.

@Darkatek7

Copy link
Copy Markdown
Author

Replies to Individual Comments

On ExecStart suggestion: Fixed - now properly uses the package path.

On timezone default: Thanks @takac! I've added timezone option with default config.time.timeZone or "UTC".

On mkSecretOption: Already using mkSecretOption for apiKey. Also added mkSecretOption for jellyfin.masterOverridePassword and postgres.password.

On jellystat-env service: Already implemented - the env file is created at /run/jellystat/env and jellystat-env.service is in the after and requires directives.

On description punctuation: All fixed - descriptions now properly end with periods.

On VPN description: Fixed markdown formatting with proper blank lines between sentences.

On jellyfin URL options: Redesigned to use hostname/port/useSsl/urlBase which auto-construct the URL with sensible defaults.

On jellyfin-setup-wizard dependency: Changed from jellyfin.service to jellyfin-setup-wizard.service as suggested.

On API key auto-detection: Currently auto-detects from nixflix.jellyfin.config.apiKey. Auto-creating API keys could be a future enhancement but requires Jellyfin API access during config.

On environment variables (JF_USE_WEBSOCKETS etc): These were actually missing! I've now added all required environment variables including JF_USE_WEBSOCKETS, IS_EMBY_API, NEW_WATCH_EVENT_THRESHOLD_HOURS, and REJECT_SELF_SIGNED_CERTIFICATES.

On unnecessary code: Removed the conditional optionalAttrs that was commented out.

On NS_USER/NS_PASSWORD: Added jellyfin.masterOverrideUser and jellyfin.masterOverridePassword options.

On POSTGRES_PASSWORD: Added auto-generated password support and jellystat-setup-db.service to set the PostgreSQL password before Jellystat connects.

@kiriwalawren kiriwalawren left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming along nicely. I can't thank you enough for this.

I have a few more comments, though.

Comment thread modules/jellystat/options/default.nix Outdated
Comment thread modules/jellystat/options/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
Comment thread modules/jellystat/default.nix Outdated
@kiriwalawren kiriwalawren marked this pull request as ready for review May 9, 2026 04:06
@kiriwalawren

Copy link
Copy Markdown
Owner

I am closing this PR because there is no way to override the listen port. There is an open PR that has been open for over a year for this issue. CyferShepard/Jellystat#346

However, the maintainer announced a rewrite of the project. And that jellystat is entering maintenance mode. So, it seems unlikely that this will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Jellystat

3 participants