disko icon indicating copy to clipboard operation
disko copied to clipboard

[feature] Impermanence integration via hook scripts for installation

Open zackw opened this issue 9 months ago • 0 comments

I would like to be able to use disko to define the partitioning of a system that uses the impermanence modules to run with an ephemeral root filesystem. An example of the sort of thing I would like to be able to do (possibly with additional setup) is shown in the attached flake.nix.

At present, this doesn't work, for two reasons. First, and most important, files that are written to the root filesystem by the installer, before impermanence gets a chance to set itself up, are lost, even if they are in a directory that impermanence tracks. (Most importantly, with the configuration in the attached flake.nix, all of /nix/var/nix is lost, as is everything in persisted subdirectories of /var.) Second, if you follow the advice in the impermanence manual to put all of /nix under persistence, disko's installation script will copy /nix/store into the ephemeral root filesystem before impermanence is up and running, which will almost certainly run the installation VM out of RAM and crash. (The attached flake.nix works around this by creating an independent, directly mounted partition for /nix/store, which I personally think is a better idea anyway, but it'd be nice if the official impermanence recommendations worked.)

To make this work as seamlessly as possible will require changes in both disko and impermanence, but I think the only thing that needs to happen on disko's side is for its installer and VM builder to permit execution of hook scripts, defined by other NixOS modules, at key moments during the process. Impermanence would want to run a hook script right after all the filesystems are created and mounted but before any other work is done (even before copy_after_disko files are copied). I can also imagine uses for a hook that executes between creating partitions and creating filesystems, and a hook that executes after installation is complete.


flake.nix

zackw avatar Mar 29 '25 16:03 zackw