[feature-request] mode to output fileSystems nix configuration
For debugging and when one doesn't want to use the module in one's NixOS configuraiton, it would be nice if disko had a fourth mode, that just prints the resulting fileSystems = { ... }; block for a nixos system.
$ disko --help
disko [options] disk-config.nix
or disko [options] --flake github:somebody/somewhere#disk-config
With flakes, disk-config is discovered first under the .diskoConfigurations top level attribute
or else from the disko module of a NixOS configuration of that name under .nixosConfigurations.
Options:
* -m, --mode mode
set the mode, either format, mount or disko
format: create partition tables, zpools, lvms, raids and filesystems
mount: mount the partition at the specified root-mountpoint
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
nix-filesystems: pirnts the `filesyStems` block of NixOS configuration
Not exactly what you are looking for, but this works for flakes nix eval .#nixosConfigurations.HOST.config.fileSystems just replace HOST with the system name. If you want a pretty output nix eval .#nixosConfigurations.HOST.config.fileSystems --json | jq should do as well
@LovingMelody sorry, I'm new to Nix — what is "works for flakes" in this context? given a (slightly patched) disko and a standalone disko config file, how can I make this expression work?
@intelfx It should work so long as your NixOS configuration is using flakes.
@LovingMelody I don't have NixOS, just a standalone disko checkout and a config file :sweat_smile:
If you want this manually, you can use nixos-generate-config --show-hardware-config --root /mnt once it's mounted (via mount mode, or disko mode). There's some extra stuff in there regarding kernel modules/drivers etc (which should be ignored if you are partitioning a disk for another system), but you mainly need the filesystem stuff.