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/samba: allow dummy conf file to be overridden #44238
Conversation
40cba14
to
0537c5a
Compare
}; | ||
environment.etc."samba/smb.conf".source = | ||
if cfg.enable then configFile | ||
else mkOptionDefault (pkgs.writeText "smb-dummy.conf" "# Samba is disabled."); |
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.
Use mkDefault
instead
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.
With mkDefault
I can't get mkForce
to override it.
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.
See #31860 for reference.
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.
Are you sure? From their definition this doesn't make any sense:
Lines 496 to 498 in fcb4254
mkOptionDefault = mkOverride 1500; # priority of option defaults | |
mkDefault = mkOverride 1000; # used in config sections of non-user modules to set a default | |
mkForce = mkOverride 50; |
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.
Yes, I had a look at this bit of code as well and can only assume that mkOverride
is doing magic. I've just tried it again and get the following error:
The unique option `environment.etc.samba/smb.conf.source' is defined multiple times, in …
Maybe @rycee can help us out.
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.
In other words, as far as I can tell this PR looks good.
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.
Oh I see, but shouldn't the best course of action then be to change the default priority of the source
value? Something like mkOverride 1200
. Because mkOptionDefault
is indicated to be the options default (aka the thing you get for options.foo.default
).
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.
@rycee, yes I am using the text
attribute. Thank you for your thorough explanation.
@infinisil, I agree that mkOptionDefault
is semantically incorrect. However if at some point the definition for the named mkOverrides ever changes the hardcoded values will have to be updated as well.
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.
All right, one more thing though: I think mkOptionDefault
should include the if statement, such that you can override it the same way if samba is enabled.
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.
Done.
This allows configuring samba clients on systems without a samba server.
0537c5a
to
5116988
Compare
Motivation for this change
This allows configuring samba clients on systems without a samba server by using mkForce.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)Alternatively, we could add an option like
dummyConfigText
to this module.