No description
Find a file
2022-11-01 20:05:10 +01:00
example tests: add simple-efi 2022-10-23 12:29:13 +02:00
tests add tests for module and cli 2022-11-01 20:05:10 +01:00
.gitignore add gitignore 2022-08-17 14:53:43 +02:00
ci.nix run all tests on ci 2022-08-25 23:31:05 +02:00
cli.nix add disko cli 2022-11-01 20:05:10 +01:00
default.nix add disko cli 2022-11-01 20:05:10 +01:00
disko add disko cli 2022-11-01 20:05:10 +01:00
flake.lock add flake 2022-08-17 14:53:51 +02:00
flake.nix add module 2022-10-29 13:23:31 +02:00
LICENSE Create LICENSE 2022-10-02 22:31:39 +02:00
module.nix add module 2022-10-29 13:23:31 +02:00
README.md add module 2022-10-29 13:23:31 +02:00
types.nix export config list in types 2022-10-23 11:36:56 +02:00

disko

nix-powered automatic disk partitioning. partition your disks declaratively NixOS style.

Installing NixOS module

You can use the NixOS module in one of the following ways:

Flakes

If you use nix flakes support:

{
  inputs.disko.url = "github:nix-community/disko";
  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
      ];
    };
  };
}

niv (Current recommendation)

First add it to niv:

$ niv add nix-community/disko

Then add the following to your configuration.nix in the imports list:

{
  imports = [ "${(import ./nix/sources.nix).disko}/modules/disko.nix" ];
}

nix-channel

As root run:

$ nix-channel --add https://github.com/nix-community/disko/archive/main.tar.gz disko
$ nix-channel --update

Then add the following to your configuration.nix in the imports list:

{
  imports = [ <disko/modules/disko.nix> ];
}

fetchTarball

Add the following to your configuration.nix:

{
  imports = [ "${builtins.fetchTarball "https://github.com/nix-community/disko/archive/main.tar.gz"}/modules/disko.nix" ];
}

or with pinning:

{
  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"
  ];
}

Using the NixOS module

{
  # checkout the example folder for how to configure different diska layouts
  disko.devices = {
    disk.sda = {
      device = "/dev/sda";
      type = "disk";
      content = {
        type = "table";
        format = "gpt";
        partitions = [
          {
            type = "partition";
            name = "ESP";
            start = "1MiB";
            end = "100MiB";
            bootable = true;
            content = {
              type = "filesystem";
              format = "vfat";
              mountpoint = "/boot";
            };
          }
          {
            name = "root";
            type = "partition";
            start = "100MiB";
            end = "100%";
            part-type = "primary";
            bootable = true;
            content = {
              type = "filesystem";
              format = "ext4";
              mountpoint = "/";
            };
          }
        ];
      };
    };
  };
}

this will configure fileSystems and other required NixOS options to boot the specified configuration.

If you are on an installer, you probably want to disable enableConfig.

disko will create the scripts disko-create and disko-mount which can be used to create/mount the configured disk layout.