NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.51k stars 13.68k forks source link

Inconsistent and sprawly NixOS image/system builder scripts #23052

Open copumpkin opened 7 years ago

copumpkin commented 7 years ago

Annoyances I've found so far:

  1. make-iso9660-image.nix and make-tarball.nix both support contents, to dump arbitrary other files to the resulting filesystem. make-disk-image.nix does not. Furthermore, the way contents is implemented varies across related scripts: make-etc.sh has a very similar structure, but understands glob patterns, UIDs, GIDs, and modes. The two mentioned earlier are stripped-down versions of the same idea, with no support for UIDs or GIDs.
  2. There's plenty of code copied and pasted between the various builders. For example, search for "!!! should use XML".
  3. There are some cool building blocks like make-ext4-fs.nix, but not all image building scripts use them, and they can likely be implemented more efficiently
  4. Some builders register the paths in the Nix database at boot time and others register it statically in the image/tarball

This is a more logical breakdown to me:

  1. Have a set of builder functions that know how to take a filesystem tree on the builder to a disk image, possibly partitioned, possibly with bootloaders, and with different target filesystem options
  2. Have another builder that knows how to make a tarball of a system tree
  3. Have some logic that knows how to take a NixOS config (and optional additional files, like contents above) to a filesystem tree
  4. A set of idiosyncratic NixOS configuration modules for individual providers (EC2, GCE, ARM systems, etc.)

I'd bet that virtually of our tarball/image/nixos-install work can then be expressed in terms of those four building blocks.

I'm volunteering to clean this all up. https://github.com/NixOS/nixpkgs/pull/23026 and https://github.com/NixOS/nixpkgs/pull/21943 are the first steps, but I plan to reduce all the sprawl as well. I think our image building story can be truly excellent and a major selling point of NixOS, but right now it's inconsistent and occasionally pretty awkward.

gavinrogers commented 6 years ago

@copumpkin I was code diving through some of these files (thinking the same thing as you) and then I found a link to here in one of your comments. I'm currently using nixos as a basis for creating system (disk) images. How can I help?

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
fgaz commented 3 years ago

Still important, stale bot :)

@copumpkin I'm the maintainer of the builds.sr.ht NixOS image, and we need UID/GID/mode support in contents to set some user configuration files. I could send a patch to fix annoyance n°1 for the make-disk-image.nix script. Would you accept such a change? Or would you prefer all the builders to be unified first?

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

fgaz commented 3 years ago

Annoyance 1 is fixed, but afaik the others remain

pinpox commented 2 years ago

Not sure if this is the right place, but would it be possible to add support for custom partitioning scripts? make-disk-image.nix would be great to generate images e.g. for personal machines if it allowed the parted script to be overriden or extended to accommodate other partition layouts like adding extra partitions or setting labels.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

fgaz commented 2 years ago

Looks like it's still the same?