NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.79k stars 13.9k forks source link

Use conditionals for all architecture dependent initrd modules #109280

Open primeos opened 3 years ago

primeos commented 3 years ago

This is a meta issue to track the changes that are required since we've merged #78430 (resulted in some channel blockers: #109252).

This is important for everything that is part of modulesClosure (allowMissing is now false):

  # Determine the set of modules that we need to mount the root FS.
  modulesClosure = pkgs.makeModulesClosure {
    rootModules = config.boot.initrd.availableKernelModules ++ config.boot.initrd.kernelModules;
    kernel = modulesTree;
    firmware = firmware;
    allowMissing = false;
  };

But for missing firmware we only print a warning: 49130f93b73e61a9e3dff31c3c13c5a9096fa969

Relevant commits:

Open/unresolved issues to consider:

Potential improvements:

xaverdh commented 3 years ago

So a quick way to find places where issues will pop up, is to look at previously successfully builds (The log of modules-shrunk.drv). Every FATAL error message from modinfo in these logs corresponds to a missing module, that will now cause the build to abort.

xaverdh commented 3 years ago

Should we add a NixOS option for allowMissing that defaults to false? Reasoning for this idea: We can fix regressions on Hydra and users could contribute fixes for other architectures but we cannot consider all custom kernel configurations (and minimal kernel configs will miss a lot of modules!)

We should consider this as a temporary stop gap measure, but what we really want to do here is make the module system less opinionated on the list of default modules.

vcunat commented 3 years ago

Perhaps have two lists? One where failure is OK and another one where failure is fatal?

xaverdh commented 3 years ago

Perhaps have two lists? One where failure is OK and another one where failure is fatal?

The thing is, we actually do want the build to fail, if somebody makes a typo in their config. So if we have a list of "optional" modules, we should somehow distinguish those cases. Moreover if somebody explicitly adds a module to their config, we should detect if its not there. But this can probably be computed in the module system. Taking the difference of the "optional default modules" minus the explicitly given modules, and only allow those to be missing.

xaverdh commented 3 years ago

@delroth since you have a custom kernel setup, would it help if the list in nixos/modules/profiles/all-hardware.nix could be separately switched off?

delroth commented 3 years ago

I think all-hardware.nix is only really used in rare situations e.g. building installer images or livecd or such, I personally don't really care about it.

Really the main issue is that the NixOS module system allows for modules merging things into a list but not for modules filtering things out of a list -- given that I have a "weird" config due to having to use a custom built kernel, I would be OK with having to manually filter out the default modules I don't have, but that's not something that can easily be done :(

(mkForce overrides the list completely, so that breaks the "other modules merging things into the list" part of the problem.)

vcunat commented 3 years ago

One way I can imagine is to convert the lists into attrsets. That's seems the usual approach to cases when you have a list in NixOS config and you actually need to remove parts.

samueldr commented 3 years ago

The image builder profile adds modules to the available kernel modules:

This profile is also used by the Raspberry Pi 4 sd image, which uses an alternate kernel and configuration. In turn, see #111683, this module is not present on that specialized configuration.

The solution should make it possible for users of the NixOS options to "maybe add modules" too. Just saying in case it wasn't the foregone and obvious conclusion :).

samueldr commented 3 years ago

An update to my last comment:

The image builder does not do this anymore. The all-hardware.nix profile is used instead.

We also do not have the Pi 4 SD image files anymore.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

samueldr commented 2 years ago

Workaround from here (actually from @cleverca22):

{
/* ... */
overlays = [
  (final: super: {
    makeModulesClosure = x:
      super.makeModulesClosure (x // { allowMissing = true; });
  })
];
/* ... */
}

Hopefully I'll find it quicker next time if I mention it here.