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
nginx service: add nested locations support #40303
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are nested locations used for?
getSubOptions = prefix: {}; | ||
getSubModules = null; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just override the description of the type (type // { description = "custom descr"; }
) to get rid of the infinite recursion, no function in lib needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work. Recursion occurs in manual generation when it tries to generate options description for locations._name_.locations._name_
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's potentially a more thorough solution now, in
Look for recursive =
in types.nix
.
cc @ncfavier
@infinisil I use them to restrict access to sublocations with password. They are useful for other settings too. |
Any update? |
Thank you for your contributions.
|
I marked this as stale due to inactivity. → More info |
I have used this for sub-locations like those:
|
This function is helpful for infinitely recursive types to stop traversing early. Without this infinitely recursive options crash Nix during documentation build.
I rebased tree atop latest master. |
@infinisil kind ping -- I'd like to merge because I use this patch, but not sure you are okay with this. Also I'm not sure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to merge this once these points are addressed :)
@@ -111,6 +112,21 @@ with lib; | |||
''; | |||
}; | |||
|
|||
locations = mkOption { | |||
type = types.attrsOf (types.hideSubTree (types.submodule self)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -7,6 +7,7 @@ | |||
|
|||
with lib; | |||
|
|||
let self = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Instead of doing the recursion here, do it in ./vhost-options.nix
by doing
diff --git a/nixos/modules/services/web-servers/nginx/vhost-options.nix b/nixos/modules/services/web-servers/nginx/vhost-options.nix
index c4e8285dc48..d687cb8ab2d 100644
--- a/nixos/modules/services/web-servers/nginx/vhost-options.nix
+++ b/nixos/modules/services/web-servers/nginx/vhost-options.nix
@@ -271,9 +271,12 @@ with lib;
};
locations = mkOption {
- type = types.attrsOf (types.submodule (import ./location-options.nix {
- inherit lib;
- }));
+ type =
+ let
+ locationsType = types.attrsOf (types.submodule (import ./location-options.nix {
+ inherit lib locationsType;
+ }));
+ in locationsType;
default = {};
example = literalExpression ''
{
Then you can take the locationsType
argument in this module (though it's passed a bit unconventional, but that's another issue), and use that directly as the type for the locations
option.
This branch has conflicts that must be resolved ( damn English ) |
It looks like the PR author isn't active anymore. I encourage others to pick this up. |
Motivation for this change
Copy locations from vhost-options.nix so can be nested.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)