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

Should formats that don't support bootloaders lib.mkForce disable them? #297

Open
b- opened this issue Feb 18, 2024 · 1 comment
Open

Should formats that don't support bootloaders lib.mkForce disable them? #297

b- opened this issue Feb 18, 2024 · 1 comment

Comments

@b-
Copy link

b- commented Feb 18, 2024

A number of the generated formats that are supported by nixos-generators don't use or support bootloaders, for example Docker, kexec, or lxc. I would like to propose that for those in particular where "installing grub" absolutely doesn't make any sense we set options like boot.loader.grub.enable = lib.mkForce false and boot.loader.systemd-boot.enable = lib.mkForce false.

This may fall squarely into idiot-proofing, but think it would improve the overall user experience because reusing an existing configuration will be easier.

I would be happy to make a PR, but I wanted to make a proposal via an Issue first before I put any effort into it, in case anyone else disagrees or has a different idea as to how this could or should be achieved.

Instead of a full PR, let me provide inline an example of what I have in mind:

# nixos-generators/formats/proxmox-lxc.nix
{modulesPath, config, lib, ...}: {
  imports = [
    "${toString modulesPath}/virtualisation/proxmox-lxc.nix"
  ];
  formatAttr = "tarball";
  fileExtension = ".tar.xz";
  boot.loader.grub.enable = lib.mkForce false;
  boot.loader.systemd-boot.enable = lib.mkForce false;
}

My thought process is that if installing a bootloader is impossible or otherwise makes no sense in a format provided by nixos-generators then adding such a setting mkForce'd to off will make reusing an existing NixOS configuration easier — for example if I wanted to package up into Docker something I was testing as a VM, I wouldn't have to touch existing bootloader settings.

Some of the formats such as kexec already disable grub (https://github.com/nix-community/nixos-generators/blob/0aa24e93f75370454f0e03747b6836ac2a2c9fca/formats/kexec.nix#L86C1-L87C1) but I think that not using lib.mkDefault or lib.mkForce in these situations might cause more confusion and frustration than not, since the resulting conflict error might not even make it clear what in your configuration is causing a conflict.

Maybe there should be some higher-up NixOS option we can toggle like boot.loader.enable that itself would override options like boot.loader.systemd-boot.enable and boot.loader.grub.enable? I'm not sure…

I understand that in general the Nix Community is pretty strongly opinionated against Nix being pretty opinionated, but given that nixos-generators is mostly a sugary wrapping around existing modules in <nixpkgs>, maybe adding a little more idiot-proofing sugar might help things? 😄 Just to be clear, I am NOT trying to impose using any particular bootloader or not on anyone in any situation, at all. I just think that bootloaders should be forcibly disabled for formats in which a bootloader inherently absolutely does not make sense.

@Lassulus
Copy link
Collaborator

sounds like a good idea. Although I'm (very) slowly trying to move most of the code here to nixpkgs itself. But until that is finished we can add those overrides here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants