-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
nixos/openldap: fix assertion #64387
Conversation
In commit d43dc68, @Mic92 split the rootpw option to allow specifying it in a file kept outside the Nix store, as an alternative to specifying the password directly in the config. Prior to that, rootpw's type was `str`, but in order to allow both alternatives, it had to become `nullOr str` with a default of `null`. So I can see why this assertion, that either rootpw or rootpwFile are specified, makes sense to add here. However, these options aren't used if the configDir option is set, so as written this assertion breaks valid configurations, including the configuration used by nixos/tests/ldap.nix. So this patch fixes the assertion so that it doesn't fire if configDir is set.
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.
Seems a simple fix; I'll merge this in several days provided noone else who actually uses OpenLDAP jumps in.
@@ -237,8 +237,8 @@ in | |||
config = mkIf cfg.enable { | |||
assertions = [ | |||
{ | |||
assertion = cfg.rootpwFile != null || cfg.rootpw != null; | |||
message = "Either services.openldap.rootpw or services.openldap.rootpwFile must be set"; | |||
assertion = cfg.configDir != null || cfg.rootpwFile != null || cfg.rootpw != 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.
Can be written as cfg.configDir == null -> cfg.rootpwFile != null || cfg.rootpw != null
for more clarity, but that's completely not important.
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.
Thanks for reviewing! I think that was how I wrote it originally and I found it more confusing that way. Maybe it's just confusing no matter how it's written. 😓
BTW what was the test that you mentioned failed before this PR? |
The LDAP tests failed during nix-instantiate when I ran: nix-build nixos/release.nix -A tests.ldap.x86_64-linux The configuration there trips the assertion as it's currently written. |
@GrahamcOfBorg test ldap |
Motivation for this change
In commit d43dc68, @Mic92 split the rootpw option to allow specifying it in a file kept outside the Nix store, as an alternative to specifying the password directly in the config.
Prior to that, rootpw's type was
str
, but in order to allow both alternatives, it had to becomenullOr str
with a default ofnull
. So I can see why this assertion, that either rootpw or rootpwFile are specified, makes sense to add here.However, these options aren't used if the configDir option is set, so as written this assertion breaks valid configurations, including the configuration used by nixos/tests/ldap.nix.
So this patch fixes the assertion so that it doesn't fire if configDir is set.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)