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

nixos/samba: allow dummy conf file to be overridden #44238

Merged
merged 1 commit into from Aug 16, 2018

Conversation

jfrankenau
Copy link
Member

Motivation for this change

This allows configuring samba clients on systems without a samba server by using mkForce.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

Alternatively, we could add an option like dummyConfigText to this module.

@jfrankenau jfrankenau changed the title nixos/samba: allow dummy conf file to be overriden nixos/samba: allow dummy conf file to be overridden Jul 30, 2018
};
environment.etc."samba/smb.conf".source =
if cfg.enable then configFile
else mkOptionDefault (pkgs.writeText "smb-dummy.conf" "# Samba is disabled.");
Copy link
Member

Choose a reason for hiding this comment

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

Use mkDefault instead

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #31860 for reference.

Copy link
Member

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:

nixpkgs/lib/modules.nix

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;

Copy link
Member Author

@jfrankenau jfrankenau Aug 3, 2018

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.

Copy link
Member

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.

Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.
@infinisil infinisil merged commit ed2148b into NixOS:master Aug 16, 2018
@jfrankenau jfrankenau deleted the samba-conf-override branch August 16, 2018 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants