NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.59k stars 13.07k forks source link

Towards unified image builders #324817

Open msanft opened 1 week ago

msanft commented 1 week ago

tl;dr

NixOS has many image builders that build an image file from a NixOS configuration, such as image.repart, system.build.isoImage, system.build.sdImage. Not only do these inconsistent interfaces create a bad UX (options being named differently but doing the same, etc.), they also make it hard to introduce new features for all of those builders due to duplication. With this, I propose to shift towards a unified image builder using systemd-repart. (i.e. the existing image.repart builder, with abstractions and default options that enable convenient builds of regularly built image types, such as the existing system.build.isoImage and system.build.sdImage). In addition to this proposition I'd like this issue to be a place for discussion on how such an interface should look like, ideally leading to a decision.

The Status Quo

We currently have (at least) 3 different publicly exposed builders that will emit a NixOS image based on a NixOS configuration:

Why is this an Issue?

Maintaining multiple builders doing similar things is tedious, especially if their work can also be done by other builders. Furthermore, all builders have wildly different configuration interfaces, making it hard for users to find which knobs they need to turn to get what they want, and even finding the correct builder for the use-case in the first place can be a hassle. Furthermore, there are features which would be great to implement for all NixOS image builders, such as build-time execution of activation scripts, making image-based appliances more immutable by not requiring a writable root filesystem.

What is desirable?

Part of this should be discussed within this issue. Personally, I propose a unified interface for building images (e.g. build.image) that should cover all current use-cases. The builder should be based on the current image.repart, as it provides the most configurability, and declarative partitioning. It also blends in very well with other systemd components, such as systemd-cryptsetup. There should still be convenience targets (think a system.build.isoImage, but based on the unified builder interface), which should be compatible with the current builder interface. For continuous development of such a unified interface, a first step could port a basic builder, and then the exisiting builders (e.g. system.build.isoImage) could be ported from their existing build scripts to the unified builder, maintaining compatibility. This would be a huge step for both installation- as well as image-based NixOS, increasing nixpkgs-internal development velocity on these topics, many of which are very desirable for NixOS in enterprise use-cases.

eclairevoyant commented 1 week ago

Unifying 3+ interfaces that do the same thing sounds pretty uncontroversial, doubt it needs an rfc :) Thanks for raising this.

msanft commented 1 week ago

Unifying 3+ interfaces that do the same thing sounds pretty uncontroversial, doubt it needs an rfc :) Thanks for raising this.

Yes, I think this part is out of question. The "RFC" part I was referring to rather meant a "discussion with an outcome" about how that new interface should look like