-
-
Notifications
You must be signed in to change notification settings - Fork 17.3k
nixos-rebuild: init build-image subcommand #347275
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
Conversation
9d2f08c to
2c768a3
Compare
2c768a3 to
f9ef933
Compare
f9ef933 to
400f664
Compare
8838a84 to
d66069c
Compare
4608fbb to
3a5e07f
Compare
Aleksanaa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been wanting to do this for a long time, thanks
3a5e07f to
30d987e
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixos-rebuild-ng-a-nixos-rebuild-rewrite/55606/25 |
|
How does this compare to the already existing I could e.g. imagine: |
|
These two do not conflict and the implementation in nixos-rebuild is very minimal. And after all the new cli isn't enabled by default, the configuration may not be in flake and we still have nix_2_3 users. |
|
I think a In addition to the arguments @Aleksanaa brought up, I believe current policy is not use new-style CLI commands in the manual and therefore relying on |
|
Happy to give both, an implementation of this feature for nixos-rebuild-ng, and a nix-bundle interface a go - but I'd like to with that wait until #359345 and/or this PR are merged to avoid too many PRs & rebases in parallel in case we decide to change anything here. So if anyone was planning on giving this a review or even test resulting images on the platforms you use, it would be great to do so soon ;) |
|
If there is nothing else, let's merge this before it conflicts again? |
Sure go ahead, if you have tested it :) |
a new sub-command to build disk-images specialized for various platforms and providers in system.build.images via the command line. `nixos-rebuild build-image --flake .#my-test-vm` exits with an error and prints a list of supported images. Add `--image-variant` to select an image, e.g.: `nixos-rebuild build-image --flake .#my-test-vm --image-variant proxmox`.
Changed due to introduction of image.baseName for isoImage, but it seems like it was "nixos.iso" instead of "cd.iso" before anyway?
a1f1fd9 to
b79f1c3
Compare
|
Resolved the merge conflicts in release notes, didn't change anything in the code. |
This was an oversight in NixOS#347275, so it's currently missing from the variants listed in nixos-rebuild build-image
This was an oversight in NixOS#347275, so it's currently missing from the variants listed in nixos-rebuild build-image
|
Could support be added for qcow images directly? Like as a image variant |
|
Also, there is a issue where large disks sizes are stuck here: is there any way to pass any override to the vm or process thats building the vm? there are some qemu flags that could stop it for being stuck at: |
|
I think it'd preferable to discuss such issues either in discourse or a new issue, but not necessarily 8 months later in a long closed PR
That's supported, as
Not really, except for overriding the specific system.build.image attribute all together, as make-disk-image.nix does not allow such overrides IMO. |
I split preparation for this into smaller PRs, after feedback:
And force-pushed this one to contain only changes to the manual & nixos-rebuild
This PR would introduce a new
nixos-rebuild build-imagesub-command to generate disk images for a given nixos configuration. I would nevertheless appreciate any feedback on the design and functionality!It's part of an attempt to bring the functionality of @Lassulus https://github.com/nix-community/nixos-generators upstream, i.e. allow users to run
to create a disk-image for digital-ocean. Or run it without arguments to get a list of available variants:
options
Each image/variant gains a new
system.build.imageattribute, which is just an alias for existing system.build-options, but provides a unified interface. Users can just import proxmox or amazon and build an image without having to wonder whether itssystem.build.amazonorsystem.build.VMA.Also, each image imports
image/file-options.nixwhich provides unified options forimage.baseName,image.extensionandimage.fileName. Those are not only useful for customization purposes, but also to be able to predict the specific image name at eval time instead of relying on shell globs to find the file inside $out.A collection of images is available in
system.build.images.${variant}after importing./image/images.nix. They can be customized per variant, viaimage.modules.${variant}and expose their own config for debbugging insystem.build.images.${variant}.passthru.config.name diffs
The following is a list of image file names, that would be changed upon a merge.
The goal here is to use a unified, predictable scheme for generated image filenames while still allowing consumers to change them centrally.
An exception is the proxmox image, where the filename is used to set default name and id of the imported VM, so changing it would affect semantics of the import. Judging existing file names, this should not be the case for others.
amazon: nixos-amazon-image-24.11pre-git-x86_64-linux.vhd -> nixos-image-amazon-24.11pre-git-x86_64-linux.vhd
azure: disk.vhd -> nixos-image-azure-24.11pre-git-x86_64-linux.vhd
digital-ocean: nixos.qcow2.gz -> nixos-image-digital-ocean-24.11pre-git-x86_64-linux.qcow2.gz
google-compute: nixos-image-24.11pre-git-x86_64-linux.raw.tar.gz -> nixos-image-google-compute-24.11pre-git-x86_64-linux.raw.tar.gz
hyperv: nixos-24.11pre-git-x86_64-linux.vhdx -> nixos-image-hyperv-24.11pre-git-x86_64-linux.vhdx
iso: nixos.iso -> nixos-image-24.11pre-git-x86_64-linux.iso
iso-installer: nixos-24.11pre-git-x86_64-linux.iso -> nixos-image-24.11pre-git-x86_64-linux.iso
kubevirt: nixos.qcow2 -> nixos-image-kubevirt-24.11pre-git-x86_64-linux.qcow2
linode: nixos-image-24.11pre-git-x86_64-linux.img.gz -> nixos-image-linode-24.11pre-git-x86_64-linux.img.gz
lxc: nixos-system-x86_64-linux.tar.xz -> nixos-image-lxc-24.11pre-git-x86_64-linux.tar.xz
lxc-metadata: nixos-system-x86_64-linux.tar.xz -> nixos-image-lxc-metadata-24.11pre-git-x86_64-linux.tar.xz
oci: nixos.qcow2 -> nixos-image-oci-24.11pre-git-x86_64-linux.qcow2
openstack: nixos.qcow2 -> nixos-image-openstack-24.11pre-git-x86_64-linux.qcow2
openstack-zfs: nixos-openstack-image-24.11pre-git-x86_64-linux.root.qcow2 -> nixos-image-openstack-zfs-24.11pre-git-x86_64-linux.root.qcow2
proxmox: vzdump-qemu-nixos-24.11pre-git.vma.zst -> vzdump-qemu-nixos-24.11pre-git.vma.zst
proxmox-lxc: nixos-system-x86_64-linux.tar.xz -> nixos-image-lxc-proxmox-24.11pre-git-x86_64-linux.tar.xz
sd-card: nixos-sd-image-24.11pre-git-x86_64-linux.img.zst -> nixos-image-sd-card-24.11pre-git-x86_64-linux.img.zst
vagrant-virtualbox: pi5fh4a6vwi40ali7bk0a8kldiakbsnn-nixos-image-vagrant-virtualbox-24.11pre-git-x86_64-linux.ova
virtualbox: nixos-24.11pre-git-x86_64-linux.ova -> nixos-image-virtualbox-24.11pre-git-x86_64-linux.ova
vmware: nixos-24.11pre-git-x86_64-linux.vmdk -> nixos-image-vmware-24.11pre-git-x86_64-linux.vmdk
closure diffs
The following is the output of nix-diff when ran on each of the images on a) the latest master commit before I branched off, and b) with this branch.
Most of them are just the propagated
nixos.system.tagschanges plus the changednixpkgspath. There are 5 exceptionssee https://gist.github.com/phaer/f2fe4d863f831141b80938a1f6c702df because github says this comment is too long "body too long" :D
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.