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
Support conditional module loading #501
Conversation
34de345
to
fed722b
Compare
@jwiegley Hi, I know you have a fairly substantial HM config under macOS. Would you mind trying this branch out? I've added code to not load the modules that are Linux specific on non-Linux platforms, which hopefully will give a more useful home-configuration.nix(5) man page and perhaps also slightly faster load time. |
@rycee Sure. It builds fine here, I'll let you know if there are any problems. |
@rycee Seems to evaluate fine for me too, and |
@rycee: Ah, I should have run Similarly with |
@league Ah, yeah. That is a bit unfortunate, I wonder how many mac users who are reusing their Linux config? In any case, I think it is not enough to do something like {
some.option = "foo";
xresources = mkIf (pkgs.hostPlatform.isLinux && cfg.enable) {
# …
};
} it would have to be mkMerge [
(mkIf (pkgs.hostPlatform.isLinux && cfg.enable) {
xresources = {
# …
};
})
{
some.option = "foo";
}
] Which is a bit unfortunate. It is probably nicest to put the Linux specific stuff in a separate file that is conditionally imported into your configuration. Maybe something like imports = [ ./foo.nix ./bar.nix ]
++ optional pkgs.hostPlatform.isLinux ./linux-conf.nix; ? |
@rycee Yeah, that would require some refactoring of what I have now. I recently built up a more extensive configuration for NixOS and other Linux machines, that uses imports and enable flags more thoroughly, and also the It's not a problem for me personally to partition those imports based on the platform, although I'm not in a rush to do it either. If you merged this I'd probably pin a version of H-M before the change until I'm ready to do that refactoring. But it's definitely not so onerous that I'd maintain a separate branch to avoid it. But I guess this experience answers the question, that it can be a breaking change for some of us. |
@league Thanks for the good explanation! I think I'll sit on this for a while and try to figure out a more smooth way to introduce this change. I guess the ideal would be to have something like |
fed722b
to
e8b6849
Compare
I realized that the condition still might be useful for future modules so I've cleaned up the PR to allow all modules even on mac but still let us use conditional inclusion for future modules. I'll still have to figure out a way to have the old modules that are Linux only, though. But I'll merge and close this for now and make a new PR when I've come up with something. |
Also make use of this functionality for the `programs.chromium` module. See #501
e8b6849
to
218a8c4
Compare
In particular, mark Linux specific modules as such.