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

Add lib.kernel #70157

Merged
merged 2 commits into from Mar 12, 2020
Merged

Add lib.kernel #70157

merged 2 commits into from Mar 12, 2020

Conversation

teto
Copy link
Member

@teto teto commented Oct 1, 2019

Motivation for this change

I would like to improve the kernel configuration system, #69013 looks blocked so I extracted what I believed is less controversial here.
I would like afterwards to get rid of the string format

extraConfig=''
OPENVSWITCH ?y
''

in favor of the more powerful structuredExtraConfig that is not documented (and thus not used) because it is presently too hard to use:

  • you either have to import lib/kernel.nix yourself
  • or understand or how the kernelItem submodule

Merging this will help move forward with #69014

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 nix-review --run "nix-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @

Remove the "version" parameter in order to make it more widely
available.
Starts making some kernel configuration helpers available.
The intent is to be able to better build and check the linux kernel
configuration.
whenAtLeast/whenBetween are made available in lib/kernel.nix but are now
scoped under whenXXX.
@edolstra
Copy link
Member

edolstra commented Oct 1, 2019

I don't think package-specific functions should be in lib. lib should be generic.

@teto
Copy link
Member Author

teto commented Oct 1, 2019

IMO, the kernel configuration is not a package-specific operation (rather platform/linux specific). There is already a library to configure the kernel that is used across nixpkgs:
system.requiredKernelConfig = with config.lib.kernelConfig; [
except it doesn't do anything sensible (the checks are just for show since we don't check the resultiung kenel config anyway).
My approach just moves the library from config.lib to lib with the goal of being more powerful:

  • really check the kernel requirements
  • allow packages to specify dependencies withotu the need to configure modules (some packages simply can't run without some kernel configuration, no need to add a module for that).

I deal with many types of kernels: out-of-tree kernels, computer-specific configurations, different versions as well as different testing setups (openvswitch/mininet/nixops-libvirtd with virtio reuquirements), builtin modules in order not to have to build an initramfs.

This is my single biggest complaint about nixos, it's all about reproducibility/dependency management, yet when it comes to the kernel we are not allowed to specify/check dependencies. It doesn't have to be like that. It's reasonibly easy to implement and can be opt-in if there are concerns.

@teto
Copy link
Member Author

teto commented Oct 11, 2019

for instance one can try to build a kernel with a configuration supposed to be checked by nixpkgs (module support is mandatory):

  kernel0 = (pkgs.linux_latest.override {
    structuredExtraConfig = { MODULES.tristate = "n"; };
  });

  kernel1 = (pkgs.linux_latest.override {
    extraConfig = ''
      MODULES n
    '';
  });

yet none of it is checked by nixpkgs, it just fails building. But for an option that doesn't break the build, it could easily go unnoticed.

There are multiple issues that show that kernel configuration checks could be useful

@teto
Copy link
Member Author

teto commented Oct 11, 2019

@infinisil
Copy link
Member

Looking good! Since this has been unnoticed for a while, is this still fresh or does it need adjustments before merging?

@teto
Copy link
Member Author

teto commented Mar 12, 2020

it's up to date ty !

@infinisil infinisil merged commit eff447b into NixOS:master Mar 12, 2020
@teto teto deleted the lib_kernel branch December 31, 2023 16:26
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

3 participants