Skip to content

nixos/paperless: add configureNginx option#385637

Merged
SuperSandro2000 merged 1 commit intoNixOS:masterfrom
SuperSandro2000:paperless-nginx
Aug 31, 2025
Merged

nixos/paperless: add configureNginx option#385637
SuperSandro2000 merged 1 commit intoNixOS:masterfrom
SuperSandro2000:paperless-nginx

Conversation

@SuperSandro2000
Copy link
Copy Markdown
Member

@SuperSandro2000 SuperSandro2000 commented Feb 27, 2025

depends on #397828

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Feb 27, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Feb 27, 2025
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 27, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 27, 2025
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 2, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 9, 2025
@SuperSandro2000
Copy link
Copy Markdown
Member Author

@erikarvstedt can you take a look, please?

Copy link
Copy Markdown
Member

@Atemu Atemu left a comment

Choose a reason for hiding this comment

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

I'm not entirely convinced why we should have this option. Please elaborate why this is necessary.

@SuperSandro2000 SuperSandro2000 force-pushed the paperless-nginx branch 3 times, most recently from 6e2e865 to 5dfc47e Compare April 12, 2025 17:18
@SuperSandro2000
Copy link
Copy Markdown
Member Author

I'm not entirely convinced why we should have this option. Please elaborate why this is necessary.

That's easy to explain: You don't want to copy the following snippet around:

{
  enable = true;
  upstreams.paperless.servers."http://${cfg.address}:${toString cfg.port}" = { };
  virtualHosts.${cfg.domain} = {
    forceSSL = lib.mkDefault true;
    locations = {
      "/".proxyPass = "http://paperless";
      "/static/" = {
        root = config.services.paperless.package;
        extraConfig = ''
          rewrite ^/(.*)$ /lib/paperless-ngx/$1 break;
        '';
      };
      "/ws/status" = {
        proxyPass = "http://paperless";
        proxyWebsockets = true;
      };
    };
  };
}

@SuperSandro2000 SuperSandro2000 marked this pull request as draft April 12, 2025 17:20
@SuperSandro2000 SuperSandro2000 force-pushed the paperless-nginx branch 2 times, most recently from 503fbf5 to cac343c Compare May 28, 2025 13:47
@SuperSandro2000 SuperSandro2000 requested a review from Atemu May 28, 2025 13:47
@SuperSandro2000 SuperSandro2000 marked this pull request as ready for review May 28, 2025 13:47
@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jun 25, 2025
@SuperSandro2000 SuperSandro2000 merged commit b62d48b into NixOS:master Aug 31, 2025
30 of 31 checks passed
@SuperSandro2000 SuperSandro2000 deleted the paperless-nginx branch August 31, 2025 19:05
Copy link
Copy Markdown
Member

@teutat3s teutat3s left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Late review.

virtualHosts.${cfg.domain} = {
forceSSL = lib.mkDefault true;
locations = {
"/".proxyPass = "http://paperless";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess we need priority here to ensure the correct order of locations in the final /etc/nginx/nginx.conf?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Isn't the most specific path matching by default?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

True, I was thinking of regex matching. Nvm as well 🙂


services.paperless.settings = lib.mkMerge [
(lib.mkIf (cfg.domain != "") {
PAPERLESS_URL = "https://${cfg.domain}";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is missing a default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, this can be. I tested this on my instance and with the test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@dcarosone
Copy link
Copy Markdown

dcarosone commented Sep 3, 2025

minor note that this caused a breaking change for prior working config, at least for one iteration of the channel between these two PRs

error: The option `services.paperless.domain' was accessed but has no value defined. Try setting the option.

So this option is now apparently needed even if not using the new nginx wrapper/support. I just set it to null as per above.

@SuperSandro2000
Copy link
Copy Markdown
Member Author

I've opened 2 days ago #439217 to fix that 😅 can you give that a shot and if it fixes your problem I am going to merge it.

@dcarosone
Copy link
Copy Markdown

Yes, that's what I meant by "as per above" (though as it turned out I had to set it to "" instead of null before the type change that's also part of that second PR.)

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

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants