disko icon indicating copy to clipboard operation
disko copied to clipboard

[feature-request] mode to output fileSystems nix configuration

Open con-f-use opened this issue 1 year ago • 6 comments

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

con-f-use avatar Feb 16 '24 15:02 con-f-use

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 avatar Feb 28 '24 11:02 LovingMelody

@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 avatar Mar 02 '24 02:03 intelfx

@intelfx It should work so long as your NixOS configuration is using flakes.

LovingMelody avatar Mar 02 '24 13:03 LovingMelody

@LovingMelody I don't have NixOS, just a standalone disko checkout and a config file :sweat_smile:

intelfx avatar Mar 02 '24 16:03 intelfx

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.

TheRealGramdalf avatar Jun 07 '24 21:06 TheRealGramdalf