Skip to content

feat: add flake-parts installer image options - #1223

Open
different-name wants to merge 1 commit into
nix-community:masterfrom
different-name:flake-offline-installer
Open

feat: add flake-parts installer image options#1223
different-name wants to merge 1 commit into
nix-community:masterfrom
different-name:flake-offline-installer

Conversation

@different-name

@different-name different-name commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Creating an offline installer configuration is already demonstrated in the disko docs, however it's pretty dense and I think a module would be a great replacement for copying that large chunk of code from the docs

This PR adds the disko-install option set to the flake-parts module, which generates installer images with dependencies & install script included

Minimal config:

disko-install.hosts = {
  my-host.disks.main = /dev/disk/by-id/some-disk-id;
};

Exhaustive config:

disko-install.hosts = {
  my-host = {
    nixosConfiguration = "my-host";
    disks.main = /dev/disk/by-id/some-disk-id;
    image = {
      formats = [ "iso-installer" "hyperv" ];
      modules = [ /*<nixos module>*/ ];
    };
    script = {
      name = "my-cool-installer";
      extraArgs = [ "--dry-run" ];
    };
  };
};

TODO

This works to generate installer images (I have tested with iso-installer) with a install-nixos-unattended script, however it still needs work:

  • Stricter typing for formats option, as it currently is just listOf str
  • Documentation
  • Tests?

@different-name
different-name force-pushed the flake-offline-installer branch from 42c513a to be79162 Compare March 6, 2026 05:42
@different-name

Copy link
Copy Markdown
Contributor Author

Marking this as ready for review, since the install script is implemented & I'm happy with the way it's configured

@different-name
different-name marked this pull request as ready for review March 6, 2026 05:56
@different-name
different-name force-pushed the flake-offline-installer branch from be79162 to e065bac Compare March 6, 2026 07:28
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/offline-automated-installation-images-for-disko/75953/1

@mightyiam

Copy link
Copy Markdown
Member

How about some tests?

@different-name

Copy link
Copy Markdown
Contributor Author

Tests is on the todo above, I don't have much experience with CI, and wanted to gauge if this is something desirable before continuing with docs & tests

@Jayman2000

Copy link
Copy Markdown
Contributor

I had actually started working on implementing a similar feature a while ago (if you want, you can check out an old version of what I had been working on here). I had gotten stuck trying to write tests for the functionality that I had added. Specifically, I thought that I needed this Nixpkgs pull request that adds a lib.strings.escapePythonBytes function to be merged before I would be able properly write tests for the functionality that I had added.

More recently, I figured out workarounds that would allow me to write correct tests even though the lib.strings.escapePythonBytes pull request still hasn’t been merged yet. As a result, I have finished my pull request, and I have submitted it as an alternative to this pull request. Compared this this pull request, I think that my pull request has a few advantages:

  • With this pull request, users need to do several different things which are normally optional: users must use disko for their partitions and filesystems, users must use flakes, and users must use flake-parts.

    With my pull request, users only need to do one thing which is normally optional: users must use disko for their partitions and filesystems.

  • With this pull request, the deployee configuration (the NixOS configuration that you are going install onto a system) gets evaluated at least twice. First, the deployee configuration is evaluated when the install medium is created. Then, the deployee configuration gets reevaluated every time an installation is performed (when disko-install is run).

    With my pull request, the deployee configuration gets evaluated once when the install medium is created. You can use that install medium as many times as you want without ever having to reevaluate the deployee configuration.

  • With this pull request, you need to specify the same disk(s) twice in different locations. The first time is in the deployee NixOS configuration as disko.devices.disk.<name>.device = "<path>";. The second time is in the flake-parts configuration as:

    disko-install.hosts = {
      my-host.disks.<name> = <path>;
    };

    With my pull request, you only need to declare disks once.

  • With this pull request, you have to explicitly add additional configuration (i.e., set the disko-install.hosts.<name> option).

    With my pull request, you don’t need to explicitly add any additional configuration. You can just create a NixOS configuration that uses disko for its partitions and filesystems, and then run this command:

    nixos-rebuild build-image --image-variant disko-unattended-install-iso

Since you have been working on a similar feature already, I would love it if you could take a look at my pull request and share your thoughts.

Also, sorry for coming out of nowhere and submitting a conflicting PR. I wish that I had submitted my work as a WIP pull request without tests a while ago so that we both didn’t end up putting in a bunch of duplicated effort.

@different-name

Copy link
Copy Markdown
Contributor Author

You're fine! Unfortunately life has gotten pretty busy for me, and I don't have much mental bandwidth to spare. So I won't be working on this for the foreseeable future

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

Successfully merging this pull request may close these issues.

4 participants