anchor.diff:      echo "running nixos-install..."
       nixos-install --root $root --no-bootloader --no-root-passwd \
         --system ${config.system.build.toplevel} --channel ${channelSources} --substituters ""
  +
  +    diskImage=nixos.raw
  +
  +    ${if diskSize == "auto" then ''
  +      ${if partitionTableType == "efi" || partitionTableType == "hybrid" then ''
  +        additionalSpace=$(( ($(numfmt --from=iec '${additionalSpace}') + $(numfmt --from=iec '${bootSize}')) / 1000 ))
  +      '' else ''
  +        additionalSpace=$(( $(numfmt --from=iec '${additionalSpace}') / 1000 ))
  +      ''}
  +      diskSize=$(( $(set -- $(du -d0 $root); echo "$1") + $additionalSpace ))
  +      truncate -s "$diskSize"K $diskImage
  +    '' else ''
  +      truncate -s ${toString diskSize}M $diskImage
  +    ''}
  +
  +    ${partitionDiskScript}
  +
  +    ${if partitionTableType != "none" then ''
  +      # Get start & length of the root partition in sectors to $START and $SECTORS.
  +      eval $(partx $diskImage -o START,SECTORS --nr ${rootPartition} --pairs)
  +
  +      mkfs.${fsType} -F -L ${label} $diskImage -E offset=$(sectorsToBytes $START) $(sectorsToKilobytes $SECTORS)K
  +    '' else ''
  +      mkfs.${fsType} -F -L ${label} $diskImage
  +    ''}
   
       echo "copying staging root to image..."
       cptofs -p ${optionalString (partitionTableType != "none") "-P ${rootPartition}"} -t ${fsType} -i $diskImage $root/* /
  
positive.code:   config
  
  , # The size of the disk, in megabytes.
    diskSize
  
    # The files and directories to be placed in the target file system.
    # This is a list of attribute sets {source, target} where `source'
    # is the file system object (regular file or directory) to be
    # grafted in the file system at path `target'.
  , contents ? []
  
  , # Type of partition table to use; either "legacy", "efi", or "none".
    # For "efi" images, the GPT partition table is used and a mandatory ESP
    #   partition of reasonable size is created in addition to the root partition.
    #   If `installBootLoader` is true, GRUB will be installed in EFI mode.
    # For "legacy", the msdos partition table is used and a single large root
    #   partition is created. If `installBootLoader` is true, GRUB will be
    #   installed in legacy mode.
    # For "none", no partition table is created. Enabling `installBootLoader`
    #   most likely fails as GRUB will probably refuse to install.
    partitionTableType ? "legacy"
  
negative.code:   rootPartition = { # switch-case
      legacy = "1";
      efi = "2";
      hybrid = "3";
    }.${partitionTableType};
  
    partitionDiskScript = { # switch-case
  