### Execute Installation to Target Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Command to run the installation on a specific device. ```console $ sudo nix run 'github:nix-community/disko/latest#disko-install' -- --flake '/tmp/config/etc/nixos#mymachine' --disk main /dev/sda ``` -------------------------------- ### Test Installation with QEMU Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Command to verify the installation by booting the target device in a virtual machine. ```console $ sudo qemu-kvm -enable-kvm -hda /dev/sda ``` -------------------------------- ### Fresh Installation Command Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Syntax for initiating a fresh NixOS installation using a specific flake and disk target. ```console sudo nix run 'github:nix-community/disko/latest#disko-install' -- --flake # --disk ``` -------------------------------- ### Configure cross-platform build Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Example configuration for building aarch64-linux images on an x86_64-linux host. ```nix disko = { imageBuilder = { enableBinfmt = true; pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; kernelPackages = inputs.nixpkgs.legacyPackages.x86_64-linux.linuxPackages_latest; }; nixpkgs.hostPlatform = "aarch64-linux"; ``` -------------------------------- ### Execute test driver Source: https://github.com/nix-community/disko/blob/master/docs/testing.md Starts the test driver with VM state persistence enabled. ```sh result/bin/nixos-test-driver --keep-vm-state ``` -------------------------------- ### Finalize installation and reboot Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Execute the final installation command and reboot the system to apply changes. ```console nixos-install reboot ``` -------------------------------- ### Download Disko Configuration Example Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Fetch a disko disk configuration file from a remote URL using `curl`. Save it locally to modify and use for partitioning your disk. ```bash cd /tmp curl https://raw.githubusercontent.com/nix-community/disko/master/example/hybrid.nix -o /tmp/disk-config.nix ``` -------------------------------- ### Configure GRUB bootloader Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Set up GRUB for EFI and BIOS systems, ensuring systemd-boot is disabled as disko manages the device installation. ```nix # ... #boot.loader.systemd-boot.enable = true; #boot.loader.efi.canTouchEfiVariables = true; boot.loader.grub.enable = true; boot.loader.grub.efiSupport = true; boot.loader.grub.efiInstallAsRemovable = true; # ... ``` -------------------------------- ### NixOS Installer Script with Disko Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md A NixOS installer script that uses Disko to partition and install the system. This script requires the `self` flake variable to be available, potentially via `specialArgs` or by defining the installer configuration within the flake.nix itself. ```nix # `self` here is referring to the flake `self`, you may need to pass it using `specialArgs` or define your NixOS installer configuration # in the flake.nix itself to get direct access to the `self` flake variable. { lib, pkgs, self, ... }: let flakeOutPaths = let collector = parent: map ( child: [ child.outPath ] ++ (if child ? inputs && child.inputs != { } then (collector child) else [ ]) ) (lib.attrValues parent.inputs); in lib.unique (lib.flatten (collector self)); dependencies = [ self.nixosConfigurations.your-machine.config.system.build.toplevel self.nixosConfigurations.your-machine.config.system.build.diskoScript self.nixosConfigurations.your-machine.config.system.build.diskoScript.drvPath self.nixosConfigurations.your-machine.pkgs.stdenv.drvPath # https://github.com/NixOS/nixpkgs/blob/f2fd33a198a58c4f3d53213f01432e4d88474956/nixos/modules/system/activation/top-level.nix#L342 self.nixosConfigurations.your-machine.pkgs.perlPackages.ConfigIniFiles self.nixosConfigurations.your-machine.pkgs.perlPackages.FileSlurp (self.nixosConfigurations.your-machine.pkgs.closureInfo { rootPaths = [ ]; }).drvPath ] ++ flakeOutPaths; closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in # Now add `closureInfo` to your NixOS installer { environment.etc."install-closure".source = "${closureInfo}/store-paths"; environment.systemPackages = [ (pkgs.writeShellScriptBin "install-nixos-unattended" '' set -eux # Replace "/dev/disk/by-id/some-disk-id" with your actual disk ID exec ${pkgs.disko}/bin/disko-install --flake "${self}#your-machine" --disk vdb "/dev/disk/by-id/some-disk-id" '') ]; } ``` -------------------------------- ### List Block Devices Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Command to identify the target device name for installation. ```console $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 1 14.9G 0 disk └─sda1 8:1 1 14.9G 0 part zd0 230:0 0 10G 0 disk ├─zd0p1 230:1 0 500M 0 part └─zd0p2 230:2 0 9.5G 0 part /mnt nvme0n1 259:0 0 1.8T 0 disk ├─nvme0n1p1 259:1 0 1G 0 part /boot ├─nvme0n1p2 259:2 0 16M 0 part ├─nvme0n1p3 259:3 0 250G 0 part └─nvme0n1p4 259:4 0 1.6T 0 part ``` -------------------------------- ### Add Disko NixOS Module using niv Source: https://github.com/nix-community/disko/blob/master/docs/HowTo.md Install Disko using niv and import its module into your configuration.nix. First, add Disko to your niv sources. ```console niv add nix-community/disko ``` ```nix { imports = [ "${(import ./nix/sources.nix).disko}/module.nix" ]; } ``` -------------------------------- ### Define Disko Configuration in flake.nix Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Example configuration for a disk layout including MBR, EFI, and root partitions. ```nix { inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; inputs.disko.url = "github:nix-community/disko/latest"; inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; outputs = { self, disko, nixpkgs }: { nixosConfigurations.mymachine = nixpkgs.legacyPackages.x86_64-linux.nixos [ ./configuration.nix disko.nixosModules.disko { disko.devices = { disk = { main = { # When using disko-install, we will overwrite this value from the commandline device = "/dev/disk/by-id/some-disk-id"; type = "disk"; content = { type = "gpt"; partitions = { MBR = { type = "EF02"; # for grub MBR size = "1M"; priority = 1; # Needs to be first partition }; ESP = { type = "EF00"; size = "500M"; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; }; }; root = { size = "100%"; content = { type = "filesystem"; format = "ext4"; mountpoint = "/"; }; }; }; }; }; }; }; } ]; }; } ``` -------------------------------- ### Legacy Disko Configuration with Table and GPT Source: https://github.com/nix-community/disko/blob/master/docs/table-to-gpt.md Example of a Disko configuration using the legacy 'table' type with 'gpt' format for disk partitioning. This configuration triggers deprecation warnings. ```nix { disko.devices.disk.example = { type = "disk"; device = "/dev/nvme0n1"; content = { type = "table"; format = "gpt"; partitions = [ { name = "ESP"; start = "0"; end = "512MiB"; fs-type = "fat32"; bootable = true; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; }; } { name = "root"; start = "512MiB"; end = "100%"; content.format = "ext4"; } ]; }; }; } ``` -------------------------------- ### CLI Command to Apply Disko Configuration Source: https://github.com/nix-community/disko/blob/master/README.md Applies a disko configuration from a Nix file to a specified disk. Use 'destroy,format,mount' modes for initial setup or re-partitioning. ```console sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount /tmp/disk-config.nix ``` -------------------------------- ### Persist EFI Boot Entries Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Command to install with the --write-efi-boot-entries flag to update host NVRAM. ```console $ sudo nix run 'github:nix-community/disko/latest#disko-install' -- --write-efi-boot-entries --flake '/tmp/config/etc/nixos#mymachine' --disk main /dev/sda ``` -------------------------------- ### Add Disko NixOS Module using nix-channel Source: https://github.com/nix-community/disko/blob/master/docs/HowTo.md Install Disko via a Nix channel. After adding and updating the channel, import the module using the path. ```console nix-channel --add https://github.com/nix-community/disko/archive/master.tar.gz disko nix-channel --update ``` ```nix { imports = [ ]; } ``` -------------------------------- ### Add Disko NixOS Module using fetchTarball Source: https://github.com/nix-community/disko/blob/master/docs/HowTo.md Include Disko by directly fetching the tarball. This example shows both a direct fetch and a pinned version with a placeholder SHA256 hash that must be replaced. ```nix { imports = [ "${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix" ]; } ``` ```nix { imports = let # replace this with an actual commit id or tag commit = "f2783a8ef91624b375a3cf665c3af4ac60b7c278"; in [ "${builtins.fetchTarball { url = "https://github.com/nix-community/disko/archive/${commit}.tar.gz"; # replace this with an actual hash sha256 = "0000000000000000000000000000000000000000000000000000"; }}/module.nix" ]; } ``` -------------------------------- ### Configure Disko Disk Layout Source: https://github.com/nix-community/disko/blob/master/docs/HowTo.md Example NixOS configuration for Disko, defining a disk with GPT partitioning. It includes an EFI System Partition (ESP) and a root partition formatted with ext4. ```nix { # checkout the example folder for how to configure different disko layouts disko.devices = { disk = { vdb = { device = "/dev/disk/by-id/some-disk-id"; type = "disk"; content = { type = "gpt"; partitions = { ESP = { type = "EF00"; size = "100M"; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; }; }; root = { size = "100%"; content = { type = "filesystem"; format = "ext4"; mountpoint = "/"; }; }; }; }; }; }; }; } ``` -------------------------------- ### Nix Flake for Disko Image Generation Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Define a NixOS configuration within a flake to generate disk images using Disko. Ensure Disko is added as an input and imported into your system modules. Adjust `imageSize` to ensure sufficient space for the NixOS installation. ```nix { description = "A disko images example"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; disko.url = "github:nix-community/disko/latest"; disko.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, disko, nixpkgs, ... }: { nixosConfigurations.myhost = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ # You can get this file from here: https://github.com/nix-community/disko/blob/master/example/simple-efi.nix ./simple-efi.nix disko.nixosModules.disko ({ config, modulesPath, ... }: { imports = [ # include this line to boot to boot the image inside a VM # "${modulesPath}/profiles/qemu-guest.nix" # On other hardware, you may need a hardware-configuration.nix as generated by nixos-generate-config or use nixos-facter (https://github.com/numtide/nixos-facter) # ./hardware-configuration.nix ]; # Optional. Useful for testing # users.users.root.initialPassword = "root"; boot.loader.grub.efiSupport = lib.mkDefault true; boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true; # shut up state version warning system.stateVersion = config.system.nixos.release; # Adjust this to your liking. # WARNING: if you set a too low value the image might be not big enough to contain the nixos installation disko.devices.disk.main.imageSize = "10G"; }) ]; }; }; } ``` -------------------------------- ### Configure VM with disko Options Source: https://github.com/nix-community/disko/blob/master/docs/interactive-vm.md Configure the interactive VM by setting NixOS options. The `virtualisation.fileSystems."/persist".neededForBoot = true;` option ensures the persistent file system is available on boot. Uncomment the `virtualisation.host.pkgs` line if running the VM on macOS. ```nix { virtualisation.vmVariantWithDisko = { virtualisation.fileSystems."/persist".neededForBoot = true; # For running VM on macos: https://www.tweag.io/blog/2023-02-09-nixos-vm-on-macos/ # virtualisation.host.pkgs = inputs.nixpkgs.legacyPackages.aarch64-darwin; }; } ``` -------------------------------- ### Initialize Nix Flake with Disko Template Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Use this command to initialize a new Nix flake project with a disko disk configuration template. This sets up the basic structure for managing your disk layout. ```bash nix flake init --template github:nix-community/disko-templates#single-disk-ext4 ``` -------------------------------- ### Execute QEMU test script Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Command to build and run the QEMU test script against a specific image file. ```bash $(nix-build ./qemu.nix)/bin/test-image ./main.raw ``` -------------------------------- ### Create QEMU test script Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md A Nix shell application script to run a generated UEFI-compatible image in QEMU. ```nix with import {}; writeShellApplication { name = "test-image"; runtimeInputs = [ qemu ]; text = '' if [ -z "$1" ]; then echo "Usage: $0 " exit 1 fi tmpFile=$(mktemp /tmp/test-image.XXXXXX) trap 'rm -f $tmpFile' EXIT cp "$1" "$tmpFile" qemu-system-x86_64 \ -enable-kvm \ -m 2G \ -cpu max \ -smp 2 \ -netdev user,id=net0,hostfwd=tcp::2222-:22 \ -device virtio-net-pci,netdev=net0 \ -drive if=pflash,format=raw,readonly=on,file=${OVMF.firmware} \ -drive if=pflash,format=raw,readonly=on,file=${OVMF.variables} \ -drive "if=virtio,format=raw,file=$tmpFile" ''; } ``` -------------------------------- ### Build image in Nix sandbox Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Commands to build the image within the Nix store and locate the result. ```bash nix build .#nixosConfigurations.myhost.config.system.build.diskoImages ls -a ./result/main.raw ``` -------------------------------- ### Import disko module and configuration Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Add the disko module and your disk-config.nix file to the imports list in configuration.nix. ```nix imports = [ ./hardware-configuration.nix "${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix" ./disk-config.nix ]; ``` -------------------------------- ### Enable binfmt emulation Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Enables binfmt support for cross-platform image building. ```nix disko.imageBuilder.enableBinfmt = true; ``` -------------------------------- ### Build VM Runner with disko Source: https://github.com/nix-community/disko/blob/master/docs/interactive-vm.md Use this command to build an interactive VM runner that includes disko functionality. Ensure you are in the correct project directory. ```bash nix run -L '.#nixosConfigurations.mymachine.config.system.build.vmWithDisko' ``` -------------------------------- ### NixOS System Configuration with Disko Source: https://github.com/nix-community/disko/blob/master/docs/disko-install.md Integrate this into your flake.nix to define disk partitioning and formatting using Disko. Ensure your hardware-configuration.nix is also included. ```nix { inputs.nixpkgs.lib.nixosSystem { system = "x86_64-linux"; # to pass this flake into your configuration (see the example below) specialArgs = {inherit self;}; modules = [ { # TODO: add your NixOS configuration here, don't forget your hardware-configuration.nix as well! boot.loader.systemd-boot.enable = true; imports = [ self.inputs.disko.nixosModules.disko ]; disko.devices = { disk = { vdb = { device = "/dev/disk/by-id/some-disk-id"; type = "disk"; content = { type = "gpt"; partitions = { ESP = { type = "EF00"; size = "500M"; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; }; }; root = { size = "100%"; content = { type = "filesystem"; format = "ext4"; mountpoint = "/"; }; }; }; }; }; }; }; } ]; }; } ``` -------------------------------- ### Generate NixOS configuration without filesystems Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Use this command to create an initial configuration.nix while excluding automatic filesystem detection, as disko will handle these settings. ```console nixos-generate-config --no-filesystems --root /mnt ``` -------------------------------- ### Create GPT Partition Labels using sgdisk Source: https://github.com/nix-community/disko/blob/master/docs/table-to-gpt.md Command-line instructions to create GPT partition labels using `sgdisk`. This is a required step for migrating to the new GPT layout. Note the kernel warning about the new table being used on next reboot or after `partprobe`/`kpartx`. ```bash # sgdisk -c 1:disk-example-ESP /dev/nvme0n1 # sgdisk -c 2:disk-example-zfs /dev/nvme0n1 Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully. ``` -------------------------------- ### Full test session summary Source: https://github.com/nix-community/disko/blob/master/docs/testing.md A summary command showing the build process for an interactive test. ```sh # nix build .#checks.x86_64-linux.simple-efi.driverInteractive ``` -------------------------------- ### Run All Tests and Checks Source: https://github.com/nix-community/disko/blob/master/CONTRIBUTING.md Execute all tests and checks defined in the project using the `nix-fast-build` command. ```bash # Run all tests and checks nix-fast-build ``` -------------------------------- ### List All Test Files Source: https://github.com/nix-community/disko/blob/master/CONTRIBUTING.md Use this command to list all Nix test files in the project, excluding the default test file. ```bash # List all test files ls tests/*.nix | grep -v default.nix ``` -------------------------------- ### disko Command Line Usage Source: https://github.com/nix-community/disko/blob/master/docs/reference.md Standard command line syntax for executing disko with a configuration file or flake. ```bash Usage: ./disko [options] disk-config.nix or ./disko [options] --flake github:somebody/somewhere#disk-config ``` -------------------------------- ### List Block Devices Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Use the `lsblk` command to identify the name of your system disk. This is crucial for correctly configuring disko to target the right device. ```console lsblk ``` -------------------------------- ### Run a Specific Test Source: https://github.com/nix-community/disko/blob/master/CONTRIBUTING.md To run a single, specific test, use `nix build` with the test's attribute name. The `-L` flag provides more detailed output. ```bash # Run a specific test by name nix build .#checks.x86_64-linux.simple-efi -L ``` -------------------------------- ### Import Disko Configuration in NixOS Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Include the generated disko configuration file in your NixOS configuration to apply the disk layout. Ensure the path to the configuration file is correct. ```nix { imports = [ ./disko-config.nix ]; } ``` -------------------------------- ### Nix Configuration for Disk Partitioning Source: https://github.com/nix-community/disko/blob/master/README.md Defines disk, partition, and filesystem configurations using Nix. Specify device, partition types (GPT, FAT32, ext4), sizes, and mount points. ```nix { { disko.devices = { disk = { my-disk = { device = "/dev/sda"; type = "disk"; content = { type = "gpt"; partitions = { ESP = { type = "EF00"; size = "500M"; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; }; }; root = { size = "100%"; content = { type = "filesystem"; format = "ext4"; mountpoint = "/"; }; }; }; }; }; }; }; } } ``` -------------------------------- ### Add Disko NixOS Module using npins Source: https://github.com/nix-community/disko/blob/master/docs/HowTo.md Integrate Disko with npins by adding it to your sources and then importing the module. This method allows for explicit version pinning. ```console npins add github nix-community disko ``` ```nix let sources = import ./npins; in { imports = [ (sources.disko + "/module.nix") ]; … } ``` -------------------------------- ### Disko Image Script Options Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md The generated Disko image script accepts options to manage files before and after formatting, and to control build memory allocation. Use `--pre-format-files` to inject secrets before formatting, and `--post-format-files` to add stateful files to the final image. ```console ./result --help Usage: $script [options] Options: * --pre-format-files copies the src to the dst on the VM, before disko is run This is useful to provide secrets like LUKS keys, or other files you need for formatting * --post-format-files copies the src to the dst on the finished image These end up in the images later and is useful if you want to add some extra stateful files They will have the same permissions but will be owned by root:root * --build-memory specify the amount of memory in MiB that gets allocated to the build VM This can be useful if you want to build images with a more involved NixOS config The default is 1024 MiB ``` ```console sudo ./result --build-memory 2048 ``` -------------------------------- ### Run Tests Matching a Pattern Source: https://github.com/nix-community/disko/blob/master/CONTRIBUTING.md This command filters tests based on a provided pattern (e.g., 'luks') using `nix eval` and `jq`, then executes each matching test with `nix build`. ```bash # Run tests matching a pattern nix eval --apply 'checks: builtins.filter (name: builtins.match "(.*luks.*)" name != null) (builtins.attrNames checks)' .#checks.x86_64-linux --json | jq -r '.[]' | xargs -I {} echo nix build .#checks.x86_64-linux.{} -L ``` -------------------------------- ### Configure virtual drive size Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Defines the size of the virtual disk image. ```nix disko.devices.disk..imageSize = "32G"; # Set your preferred size ``` -------------------------------- ### Define Partition Tables Source: https://github.com/nix-community/disko/blob/master/docs/upgrade-guide.md Remove the type = "partition" field as partition types are now implicitly handled within the table structure. ```nix { type = "partition"; name = "ESP"; start = "1MiB"; end = "100MiB"; part-type = "primary"; } ``` ```nix { name = "ESP"; start = "1MiB"; end = "100MiB"; part-type = "primary"; } ``` -------------------------------- ### Configure custom image name Source: https://github.com/nix-community/disko/blob/master/docs/disko-images.md Sets a custom filename for the generated disk image instead of the default drive name. ```nix disko.devices.disk..imageName = "nixos-x86_64-linux-generic-btrfs"; # Set your preferred name ``` -------------------------------- ### Verify Disk Mounts Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Check if the disks have been successfully formatted and mounted by using the `mount` command and filtering for `/mnt`. This confirms disko's operations. ```console mount | grep /mnt ``` -------------------------------- ### Run NixOS Tests in Parallel with nix-fast-build Source: https://github.com/nix-community/disko/blob/master/docs/testing.md Execute NixOS tests concurrently using `nix-fast-build`. Adjust `-j` and `--eval-workers` based on your system's resources (RAM and CPU cores) to optimize build times without causing system unresponsiveness or excessive swapping. ```sh nix shell nixpkgs#nix-fast-build nix-fast-build --no-link -j 2 --eval-workers 2 --flake .#checks ``` -------------------------------- ### Build interactive test driver Source: https://github.com/nix-community/disko/blob/master/docs/testing.md Compiles the test driver to allow for interactive debugging of the VM environment. ```sh nix build .#checks.x86_64-linux.simple-efi.driverInteractive ``` -------------------------------- ### CLI Usage: ./disko Source: https://github.com/nix-community/disko/blob/master/docs/reference.md The primary command for executing disk configuration scripts defined in Nix files or flakes. ```APIDOC ## CLI Usage: ./disko ### Description Executes disk configuration based on a provided Nix file or a flake URI. ### Usage `./disko [options] disk-config.nix` `./disko [options] --flake github:somebody/somewhere#disk-config` ### Options - **-m, --mode** (string) - Optional - Set the mode: destroy, format, mount, format,mount, or destroy,format,mount. - **-f, --flake** (string) - Optional - Fetch the disko config relative to this flake's root. - **--arg** (string) - Optional - Pass value to nix-build (e.g., set disk-names). - **--argstr** (string) - Optional - Pass value to nix-build as a string. - **--root-mountpoint** (string) - Optional - Where to mount the device tree (default: /mnt). - **--dry-run** (flag) - Optional - Show the path to the script instead of running it. - **--no-deps** (flag) - Optional - Avoid adding another dependency closure to an in-memory installer. - **--debug** (flag) - Optional - Run with set -x. - **--yes-wipe-all-disks** (flag) - Optional - Skip the safety check for destroying partitions. ``` -------------------------------- ### List All Tests with Nix Eval Source: https://github.com/nix-community/disko/blob/master/CONTRIBUTING.md This command uses `nix eval` to list all available tests for the x86_64-linux platform in JSON format, then uses `jq` to extract and sort the test names. ```bash # List all tests using nix eval nix eval --apply builtins.attrNames .#checks.x86_64-linux --json | jq -r '.[]' | sort ``` -------------------------------- ### Define ZFS Datasets Source: https://github.com/nix-community/disko/blob/master/docs/upgrade-guide.md Use zfs_fs for filesystems and zfs_volume for volumes. The size attribute is restricted to zfs_volume types. ```nix { datasets = { zfs_fs = { type = "zfs_fs"; mountpoint = "/zfs_fs"; options."com.sun:auto-snapshot" = "true"; }; zfs_unmounted_fs = { type = "zfs_fs"; options.mountpoint = "none"; }; zfs_legacy_fs = { type = "zfs_fs"; options.mountpoint = "legacy"; mountpoint = "/zfs_legacy_fs"; }; zfs_testvolume = { type = "zfs_volume"; size = "10M"; content = { type = "filesystem"; # ... } ``` -------------------------------- ### Run a specific test Source: https://github.com/nix-community/disko/blob/master/docs/testing.md Executes a single test suite defined in the disko project. ```sh nix build --no-link .#checks.x86_64-linux.simple-efi ``` -------------------------------- ### Move disko configuration to NixOS directory Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Transfer the previously generated disk-config.nix file to the target system's configuration directory. ```console mv /tmp/disk-config.nix /mnt/etc/nixos ``` -------------------------------- ### Configure BTRFS Subvolumes Source: https://github.com/nix-community/disko/blob/master/docs/upgrade-guide.md Define BTRFS subvolumes with explicit mountpoints to ensure they are mounted. Subvolumes without a mountpoint will remain unmounted. ```nix content = { type = "btrfs"; # BTRFS partition is not mounted as it doesn't set a mountpoint explicitly subvolumes = { # This subvolume will not be mounted "SYSTEM" = { }; # mounted as "/" "SYSTEM/rootfs" = { mountpoint = "/"; }; # mounted as "/nix" "SYSTEM/nix" = { mountOptions = [ "compress=zstd" "noatime" ]; mountpoint = "/nix"; }; # This subvolume will not be mounted "DATA" = { }; # mounted as "/home" "DATA/home" = { mountOptions = [ "compress=zstd" ]; mountpoint = "/home"; }; # mounted as "/var/www" "DATA/www" = { mountpoint = "/var/www"; }; }; }; ``` -------------------------------- ### Configure Disk Device in Disko Configuration Source: https://github.com/nix-community/disko/blob/master/docs/quickstart.md Edit the disko configuration file to specify the correct disk device name. Replace `` with the actual device identifier obtained from `lsblk`. ```nix # ... main = { type = "disk"; device = ""; content = { type = "gpt"; # ... ``` -------------------------------- ### Interact with VM shell Source: https://github.com/nix-community/disko/blob/master/docs/testing.md Opens a terminal session inside the running VM from the IPython prompt. ```python machine.shell_interact() ``` -------------------------------- ### Add Disko NixOS Module using Flakes Source: https://github.com/nix-community/disko/blob/master/docs/HowTo.md Integrate Disko into your NixOS configuration using flakes. Ensure to replace 'yourhostname' and 'x86_64-linux' with your system's specific details. ```nix { inputs.disko.url = "github:nix-community/disko/latest"; inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; outputs = { self, nixpkgs, disko }: { # change `yourhostname` to your actual hostname nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem { # change to your system: system = "x86_64-linux"; modules = [ ./configuration.nix disko.nixosModules.disko ]; }; }; } ``` -------------------------------- ### Validate VM state with extraTestScript Source: https://github.com/nix-community/disko/blob/master/docs/testing.md Python commands used within the test script to verify disk and mount configurations. ```python machine.succeed("test -b /dev/md/raid1"); machine.succeed("mountpoint /"); ``` -------------------------------- ### Updated Disko Configuration with GPT Layout Source: https://github.com/nix-community/disko/blob/master/docs/table-to-gpt.md The corrected Disko configuration using the new `gpt` layout type. This version replaces the legacy `table` type, removes the `format` field, converts partitions to an attribute set with `name` as the key, and adds a `priority` field. ```nix { disko.devices.disk.example = { type = "disk"; device = "/dev/nvme0n1"; content = { type = "gpt"; partitions = { ESP = { size = "512MiB"; type = "EF00"; priority = 1; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "umask=0077" ]; }; }; root = { size = "100%"; priority = 2; content.format = "ext4"; }; }; }; }; } ``` -------------------------------- ### Define LVM Logical Volumes Source: https://github.com/nix-community/disko/blob/master/docs/upgrade-guide.md Remove the explicit type = "lvm_lv" field as it is no longer required when defined within an lvm_vg. ```nix { type = "lvm_lv"; size = "10G"; # ... } ``` ```nix { size = "10G"; # ... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.