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

Slightly change services.nginx.configuration to allow for merging #54

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MagicRB
Copy link
Collaborator

@MagicRB MagicRB commented Dec 17, 2024

This might break someone's config an is untested, but without it, the following won't work:

[
  {
    services.nginx.configuration = [
      {
        http."" = {
          ...
        };
      }
    ];
  }
  {
    services..nginx.configuration = [
      {
        stream."" = {
          ...
        };
      }
    ];
  }
]

currently that'll fail with

error: The option `services.nginx.configuration' is defined multiple times while it's expected to be unique.

which is less than ideal for composability.

EDIT: this will break everything, 100% and also introduces infrecs in its current form

@MagicRB MagicRB marked this pull request as draft December 17, 2024 13:10
@MagicRB MagicRB force-pushed the nginx-slight-nginx-type-change branch 3 times, most recently from 41c0fe9 to 908919e Compare December 17, 2024 13:53
@MagicRB
Copy link
Collaborator Author

MagicRB commented Dec 17, 2024

After some friendly back and forth with the nix command line I managed to make it work.

@MagicRB MagicRB force-pushed the nginx-slight-nginx-type-change branch from 908919e to 8d952b2 Compare December 17, 2024 13:58
@MagicRB
Copy link
Collaborator Author

MagicRB commented Dec 17, 2024

This exploration led me to a different issue, Nginx doesn't merge http { ... } blocks, which makes sense, but that means that "mixins" such as:

{lib, ...}: {
  services.nginx.configuration = lib.mkBefore {
    http."" = {
      server."" = {
        listen = ["80" "default_server"];

        location."/" = {
          return = ["301" "https://$$host$$request_uri"];
        };
      };
    };
  };
}

end up in their own HTTP block and cannot set defaults and are unaffected by other mixins, in other words they're useless. Not really sure what's the solution in this case. Composability of Apache and Nginx modules is horrible due to this, only way to compose is to use the runtime include = [] mechanism, which is okay I guess but not great.

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.

1 participant