Declarative disk partitioning and formatting using nix [maintainer=@Lassulus]
Go to file
Baitinq e1927693e3
Support optional keyfile for luks encrypted partitions
If the keyfile attribute is not present it will omit any keyfile luks
configuration and instead will make the user be prompted for any
passphrases.
2022-08-24 16:48:31 +02:00
example add flag support 2022-08-19 09:52:12 +02:00
lib Support optional keyfile for luks encrypted partitions 2022-08-24 16:48:31 +02:00
tests use findmnt and mount with X-mount.mkdir 2022-08-17 15:55:07 +02:00
.gitignore add gitignore 2022-08-17 14:53:43 +02:00
ci.nix add ci.nix 2018-09-13 21:55:14 +02:00
default.nix disko: get rid of impure imports 2022-08-17 14:53:43 +02:00
flake.lock add flake 2022-08-17 14:53:51 +02:00
flake.nix add flake 2022-08-17 14:53:51 +02:00
README.md README: fix the example 2022-08-17 15:28:24 +02:00

disko

nix-powered automatic disk partitioning

Usage

Master Boot Record

This is how your iso configuation may look like

/etc/nixos/configuration.nix

{ pkgs, modulesPath, ... }:
let
  disko = pkgs.callPackage (builtins.fetchGit {
    url = "https://github.com/nix-community/disko";
    ref = "master";
  }) {};
  cfg = {
    type = "devices";
    content = {
      sda = {
        type = "table";
        format = "msdos";
        partitions = [{
          type = "partition";
          part-type = "primary";
          start = "1M";
          end = "100%";
          bootable = true;
          content = {
            type = "filesystem";
            format = "ext4";
            mountpoint = "/";
          };
        }];
      };
    };
  };
in {
  imports = [
    (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
  ];
  environment.systemPackages = with pkgs;[
    (pkgs.writeScriptBin "tsp-create" (disko.create cfg))
    (pkgs.writeScriptBin "tsp-mount" (disko.mount cfg))
  ];
  ## Optional: Automatically creates a service which runs at startup to perform the partitioning
  #systemd.services.install-to-hd = {
  #  enable = true;
  #  wantedBy = ["multi-user.target"];
  #  after = ["getty@tty1.service" ];
  #  serviceConfig = {
  #    Type = "oneshot";
  #    ExecStart = [ (disko.create cfg) (disk.mount cfg) ];
  #    StandardInput = "null";
  #    StandardOutput = "journal+console";
  #    StandardError = "inherit";
  #  };
  #};
}

After nixos-rebuild switch this will add a tsp-create and a tsp-mount command:

  • tsp-create: creates & formats the partitions according to tsp-disk.json
  • tsp-mount: mounts the partitions to /mnt

GUID Partition Table, LVM and dm-crypt

See examples/