Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: recyclarr #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: recyclarr #44

wants to merge 1 commit into from

Conversation

elsbrock
Copy link

@elsbrock elsbrock commented Mar 9, 2025

Add the recyclarr service. This enables users to import custom settings from eg. the TRaSH guide easily.

Recyclarr is available in nixpkgs-unstable, but I had to update the lockfile as we were tracking an older version.

Unlike the upstreamed module the config file can be referenced as path. This way we can reference the Sonarr and Radarr API keys using the !env_file macro, example:

radarr:
  movies:
    base_url: "http://localhost:7878"
    api_key: !env_var RADARR_API_KEY
...

By default, it is started via timer on a daily basis - maybe we want to expose that option too? I also did not integrate this with the VPN.

I was unable to nix build the docs for some reason:

❯ nix build
error: builder for '/nix/store/j0nrvhq037s3jmbx34j9isngz96p86zp-mk-pandoc.drv' failed with exit code 1;
       last 7 log lines:
       >
       > In /nix/store/n2z5y3mqrmzjg554c1xbhv913qbr8yqs-mk-pandoc/bin/mk-pandoc line 15:
       > timestamp="$(date -d @$(git show -s --format=%ct) -u "+%Y-%m-%d - %H:%M:%S %Z")"
       >                       ^-------------------------^ SC2046 (warning): Quote this to prevent word splitting.
       >
       > For more information:
       >   https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
       For full logs, run 'nix log /nix/store/j0nrvhq037s3jmbx34j9isngz96p86zp-mk-pandoc.drv'.
error: 1 dependencies of derivation '/nix/store/rc39n9rwpk4x7pw0app81wwamimyavrb-mk-pandoc-package.drv' failed to build

Hope this is useful.

@elsbrock
Copy link
Author

elsbrock commented Mar 9, 2025

Here's an example of how I use it:

services.nixarr = {
    enable = true;
    # ... other stuff
    recyclarr = {
      enable = true;
      configFile = ./recyclarr.yaml;
    };
    # ...
};
Example recyclarr.yaml
sonarr:
  series:
    base_url: "http://localhost:8989"
    api_key: !env_var SONARR_API_KEY
    quality_definition:
      type: series
    delete_old_custom_formats: true
    custom_formats:
      - trash_ids:
          - 85c61753df5da1fb2aab6f2a47426b09 # BR-DISK
          - 9c11cd3f07101cdba90a2d81cf0e56b4 # LQ
          - 47435ece6b99a0b477caf360e79ba0bb # x265 (HD)
          - fbcb31d8dabd2a319072b84fc0b7249c # Extras
        assign_scores_to:
          - name: WEB-DL (1080p)
            score: -10000

radarr:
  movies:
    base_url: "http://localhost:7878"
    api_key: !env_var RADARR_API_KEY
    quality_definition:
      type: movie
    delete_old_custom_formats: true
    custom_formats:
      - trash_ids:
          - 570bc9ebecd92723d2d21500f4be314c # Remaster
          - eca37840c13c6ef2dd0262b141a5482f # 4K Remaster
          - e0c07d59beb37348e975a930d5e50319 # Criterion Collection
          - 9d27d9d2181838f76dee150882bdc58c # Masters of Cinema
          - db9b4c4b53d312a3ca5f1378f6440fc9 # Vinegar Syndrome
        assign_scores_to:
          - name: HD Bluray + WEB
            score: 25

Copy link
Owner

@rasmus-kirk rasmus-kirk left a comment

Choose a reason for hiding this comment

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

This looks to be in really good shape. As mentioned on discord the build failure is on me, since I updated my nix website builder to be reproducible, which yielded an annoying bug. But I fixed it now!

I only have a few nitpicks, and:

By default, it is started via timer on a daily basis - maybe we want to expose that option too.

Yeah, that would be best. As long as the default is sane, I think daily is absolutely fine.

I also did not integrate this with the VPN.

That's a requirement for any nixarr submodule, so I would really prefer that. Check out the radarr/sonarr submodules and just copy over the boilerplate config for VPN (and change the names lol), that should be fine.

};

configFile = mkOption {
type = types.path;
Copy link
Owner

Choose a reason for hiding this comment

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

This should probably just be an attribute set, and then converted into yaml. Then a user wouldn't have to write a seperate yaml file, and could just write recyclarr.config.sonarr.base_url = "http://localhost:8989".

Copy link
Author

@elsbrock elsbrock Mar 10, 2025

Choose a reason for hiding this comment

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

In many cases you will find provided profiles, and they're all in plain YAML (eg. TRaSH Guide provides YAML examples). Maybe we could offer both? Upstream uses attrsets.

Copy link
Owner

Choose a reason for hiding this comment

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

I actually like both, it would be "unclean" for nixpkgs, but Nixarr is meant to be more specialized and opinionated so it could work. Just make sure that the options are mutually exclusive and document the fact.

Copy link
Author

Choose a reason for hiding this comment

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

Added it. I also tried mapping the yaml file to the new attrset option, but no native YAML support in nix, and readJSON bails if the YAML contains comments.

@rasmus-kirk
Copy link
Owner

Also, not for this PR, but would it make sense to add a wiki page for this?

@elsbrock
Copy link
Author

Thanks for the review!

For the actual configuration there's plenty of information on recyclarr and TRaSH guide. What else do you think we should document?

@elsbrock
Copy link
Author

By default, it is started via timer on a daily basis - maybe we want to expose that option too.

Yeah, that would be best. As long as the default is sane, I think daily is absolutely fine.

👍

I also did not integrate this with the VPN.

That's a requirement for any nixarr submodule, so I would really prefer that. Check out the radarr/sonarr submodules and just copy over the boilerplate config for VPN (and change the names lol), that should be fine.

I didn't do it because recyclarr does not expose a port and is just a CLI command. When starting up, it syncs some Github repos, not sure if we should route that through VPN.

@rasmus-kirk
Copy link
Owner

I didn't do it because recyclarr does not expose a port and is just a CLI command. When starting up, it syncs some Github repos, not sure if we should route that through VPN.

Makes sense, then don't do it. Once the other stuff is fixed, I'll merge it.

Add the recyclarr service.
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.

2 participants