Skip to content

Latest commit

 

History

History
88 lines (80 loc) · 3.06 KB

filesystem.org

File metadata and controls

88 lines (80 loc) · 3.06 KB

Options

  • aquaris.filesystem
    • tools: List of extra packages available to the format & mount scripts
    • disks.<name>
      • device: Path to the disk device file (set via attribute name)
      • type: Partition table type
      • partSep: Separator text between disk path and partition number. Examples:
        • /dev/sda1 → empty string
        • /dev/nvme0n1p1 → “p”
        • /dev/disk/by-id/foo-part1 → “-part”
      • partitions.<name>
        • device: Path to the partition device file (set automatically via name of respective disk & position in partition list)
        • type: Partition type (read by sfdisk)
        • size: Size of the partition (null fills remaining space on disk)
        • content: Can be a filesystem or zpool
          • filesystem
            • type: Filesystem type (read by mkfs)
            • mkfsOpts: Options for mkfs
            • mountpoint: Mount point of the filesystem
            • mountOpts: Options for mount
          • zpool: should be a zpool reference (set via helper function, see example for more information)
    • zpools.<name>
      • name: Name of the zpool (set via attribute name)
      • poolOpts: Options set on pool creation
      • rootOpts: Default options for all datasets
      • datasets.<name>
        • name: Name of the dataset (set via attribute name)
        • mountpoint: Mount point of the dataset
        • options: Extra options of the dataset

Example

{
  aquaris.filesystem =
    # partition content helper functions
    { filesystem, zpool, ... }: {
      disks = {
        # no need to set partSep, as the default value "-part"
        # works for disks referenced via /dev/disk/by-*
        # (which is the recommended method)
        "/dev/disk/by-id/foobar".partitions = [
          {
            type = "uefi"; # EFI system partition
            size = "512M";
            content = filesystem {
              type = "vfat";
              mountpoint = "/boot";
            };
          }

          # zpool helper function:
          # takes a function that extracts a pool
          # from the set of all defined pools
          { content = zpool (p: p.rpool); }
        ];
      };

      zpools.rpool.datasets = {
        # default mountpoint = all but the first part of the dataset name
        "nixos/nix" = { }; # mountpoint = /nix
        "nixos/home/user" = { }; # mountpoint = /home/user

        # parent datasets are created automatically
        # "nixos" = {};
        # "nixos/home" = {};
      };
    };
}

See also the full example

How to run

This library exports two scripts & and accompanying executables under nixosConfigurations.<name>.config.aquaris.filesystem:

  • _formatScript
  • _format
  • _mountScript
  • _mount

The formatter will not delete zpools that are already defined. Both scripts create & manage dependent resources in the correct order, including bind mounts.

See also the installer template