nixos/image: systemd-repart based GPT image builder#245250
nixos/image: systemd-repart based GPT image builder#245250RaitoBezarius merged 4 commits intoNixOS:masterfrom
Conversation
RaitoBezarius
left a comment
There was a problem hiding this comment.
Very good! My biggest beef is the namespacing. :)
There was a problem hiding this comment.
I think it would be better to have a derivation that takes a bootspec as input and outputs repart definitions as output instead of having a DSL at the nix expression Level for setting partition contents.
This will also make it easier to have this as a standalone script that builds images outside of the nix store and makes the builder usable outside of NixOS
|
Would be nice to add or document that you can run From To get a working NixOS (non appliance) image if nix binary is in the target image Like here: |
Add a re-usable function that converts an attrset to a directory containing systemd definition files.
The bootspec does not contain all the information necessary to build an image. Additionally, if we statically assemble an image, and not rely on the generation mechanism, bootspec doesn't really benefit us. We can just use the normal templating mechanisms Nix provides. The issue bootspec really addresses (at least to me) is that it has all the information in place for a bootloader installer that cannot rely on normal templating in Nix.
Outside NixOS, you should probably just use systemd-repart directly or use mkosi wich also uses systemd-repart under the hood.
I want to address this outside of this PR. This PR really just adds the NixOS primitives to create an image with systemd-repart. I believe this is also a more elegant approach. The way I envision to eventually create a fully working Nix image (that also supports generations and can be used by qemu-vm.nix) is by creating all the necessary pieces in separate derivations (or at least outside the image builder itself) and just copy the resulting files to the right spots inside the image via the primitives exposed in |
|
@ofborg test systemd-sysupdate systemd-repart.basic appliance-repart-image |
Description of changes
Add a new module to build images via
systemd-repart. This module exposes a shallow wrapper aroundsystemd-repartthat can be used to assemble appliance images by populating the Efi System Partition (ESP) yourself.The eventual ambitions for this image builder are much larger though:
make-disk-image.nixfor all GPT/UEFI use cases (including as the default image creator for qemu-vm.nix)Generally, this module wants to remain a shallow wrapper around
systemd-repartand all additional funcitonality should be implemented outside of this module (e.g. populating an ESP) and then just copy into the image via the provided mechanisms.I'm not sure where the docs should go. I feel they are too early in the manual. Also these are not really reference material, so I'm not sure if they even belong in the manual. Maybe nix.dev is a better place?
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)