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

disko-install build the whole system before format the hard drive #942

Open
cmerbach opened this issue Jan 16, 2025 · 5 comments
Open

disko-install build the whole system before format the hard drive #942

cmerbach opened this issue Jan 16, 2025 · 5 comments

Comments

@cmerbach
Copy link

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?

@Mic92
Copy link
Member

Mic92 commented Jan 16, 2025

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.

@cmerbach
Copy link
Author

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?

@Mic92
Copy link
Member

Mic92 commented Jan 17, 2025

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.

@Mic92
Copy link
Member

Mic92 commented Jan 17, 2025

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

@Mic92
Copy link
Member

Mic92 commented Jan 17, 2025

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.

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