disko
disko copied to clipboard
disko-install build the whole system before format the hard drive
When i am running disko-install like:
sudo nix run 'github:nix-community/disko/latest#disko-install' -- --flake <flake-url>#<flake-attr> --disk <disk-name> <disk-device>
as described in the documentation, what is the reason for, the entire system being built before the hard drive or device is formatted? The issue arises when I use a USB stick or an installer to install NixOS without using nixos-everywhere. This causes an "out of space" error because disko-install tries to build everything configured in my flakes, including all packages, and then writes them to the specified disk.
What is the logic behind this approach? My understanding would be that the target drive should first be formatted, and then NixOS should be installed directly onto it.
Or do i misunderstood the using7usecase of nixos-install?
What is the logic behind this approach? My understanding would be that the target drive should first be formatted, and then NixOS should be installed directly onto it. Or do i misunderstood the using7usecase of
nixos-install?
One use case was to have flash usb sticks from your current work-station. That's why it operates on /nix/store instead of the target nixos store. However maybe this behavior could be configurable. Alternative would be to operate on the target store but use /nix/store only as a substituter, for my original use case this would be only annoying if I have to build a few things for a machine and than reformat.
I think I might understand why you are doing this. However, based on my reading of the documentation—or at least my understanding of it—it seems that the device should be formatted first, followed by a nix installation. But this is not what happens in practice.
I noticed there are two components: disko and disko-install. disko appears to be doing the correct thing, as it partitions the device using a configuration file. In contrast, disko-install uses a module where you can overwrite the parameter like: device = lib.mkDefault "/dev/change/this";
If you are running disko from a productive system, I think it would also make much more sense and be more practical if the device were formatted first and then everything was installed or transferred to it.
For example, if you want to install a new machine and only have a NixOS installer USB stick along with a Nix configuration containing many packages, the process runs out of space. This is because it downloads everything first and tries to store it in RAM or on the USB stick, instead of formatting the target device first and then installing everything directly onto it.
This seems like the intuitive approach for anyone using disko-install, and it is also what I understand from the documentation. If this is not the intended use of the tool, could you please clarify?
The device is overridable because one cannot predict what device path you get if you add a removable device to a machine. Since disko will use gpt labels for mounting this will work on boot. It shouldn't be an issue if you run disko-install from a live system because you can just provide the same arguments.
Regarding the second point I already provided the background and potential solution in my previous response.
The current workaround would be to make the installer contain the nixos closure to be installed already upfront: https://github.com/nix-community/disko/blob/master/docs/disko-install.md#using-disko-install-in-an-offline-installer
If you want your workflow to be supported by disko-install, you can add a new flag that makes the nix build operate on the new store similar to nixos-anywhere:
https://github.com/nix-community/nixos-anywhere/blob/97b45ac774699b1cfd267e98a8bdecb74bace593/src/nixos-anywhere.sh#L576
I don't need this feature, so I likely won't implement this.
Hi! I’m chiming in because I went down the same rabbit hole. I came across a blog post on setting up a complete (“0-100”) Nix installation from flakes, which mentioned disko—but they did not use disko-install. After reading the README, I assumed I could define my entire system and partition layout in one flake repository, then run a single command from a live image to install.
Once I found this issue and looked at the disko-install documentation, the actual use case for that tool became clear. It might be worth adding a note in the docs to highlight that if you’re plan bootstrapping NixOS from a live image, it may not work as expected (especially if your configuration is large).
Facing the same issue as I am trying to streamline the installation of new hosts. It seems like (as part the linked issue), the best approach atm is to run disko first, and then nixos-install. Should be trivial but slightly annoying to iterate on on live hosts rather than VMs 😆
Edit: to be clear, I am trying to figure a workflow where I dont need two machines with nix installed.
I just stumbled upon this after some time debugging my first attempt at disko-install. I believe my grief is mostly with the documentation of disko-install, where it could (should?) be mentioned that the configuration is being built first and that that might cause out-of-space errors depending on what machine you build on.
As for me, I will stick with disko + nixos-install, although it is a bit less satisfactory as I cannot see a way to inject the label of the disk seen from the installation medium in a clean way (contrary to disko-install's --disk argument).
Took me some time to figure this out since the error message I get is just
/nix/store/.../bin/.disko-install-wrapped: line 234: artifacts[1]: unbound variable