disko/docs/HowTo.md

178 lines
3.6 KiB
Markdown
Raw Normal View History

# How-to Guide: Disko
## How to use Disko without NixOS
TODO: Still to be documented
## Upgrading From Older disko versions
TODO: Include documentation here.
2023-09-15 08:56:40 +03:00
For now, see the
[upgrade guide](https://github.com/JillThornhill/disko/blob/master/docs/upgrade-guide.md)
## Installing NixOS module
You can use the NixOS module in one of the following ways:
<details>
<summary>Flakes (Current recommendation)</summary>
If you use nix flakes support:
2023-09-15 08:56:40 +03:00
```nix
{
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
];
};
};
}
```
2023-09-15 08:56:40 +03:00
</details>
<details>
<summary>niv</summary>
2023-06-05 11:23:08 +03:00
2023-09-15 08:56:40 +03:00
First add it to [niv](https://github.com/nmattia/niv):
```console
2023-12-21 18:50:48 +03:00
niv add nix-community/disko
```
2023-09-15 08:56:40 +03:00
Then add the following to your configuration.nix in the `imports` list:
```nix
{
2024-03-24 03:27:02 +03:00
imports = [ "${(import ./nix/sources.nix).disko}/module.nix" ];
}
```
2023-09-15 08:56:40 +03:00
2024-04-05 12:42:17 +03:00
</details>
<details>
<summary>npins</summary>
First add it to [npins](https://github.com/andir/npins):
```console
npins add github nix-community disko
```
Then add the following to your configuration.nix in the `imports` list:
```nix
let
sources = import ./npins;
disko = import sources.disko {};
in
{
imports = [ "${disko}/module.nix" ];
}
```
</details>
<details>
<summary>nix-channel</summary>
2023-09-15 08:56:40 +03:00
As root run:
```console
2023-12-21 18:50:48 +03:00
nix-channel --add https://github.com/nix-community/disko/archive/master.tar.gz disko
nix-channel --update
```
2023-09-15 08:56:40 +03:00
Then add the following to your configuration.nix in the `imports` list:
```nix
{
2024-03-24 03:27:02 +03:00
imports = [ <disko/module.nix> ];
}
```
2023-09-15 08:56:40 +03:00
</details>
<details>
<summary>fetchTarball</summary>
2023-09-15 08:56:40 +03:00
Add the following to your configuration.nix:
2023-09-15 08:56:40 +03:00
```nix
{
imports = [ "${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix" ];
}
```
2023-09-15 08:56:40 +03:00
or with pinning:
```nix
{
imports = let
# replace this with an actual commit id or tag
commit = "f2783a8ef91624b375a3cf665c3af4ac60b7c278";
2023-06-05 11:23:08 +03:00
in [
"${builtins.fetchTarball {
url = "https://github.com/nix-community/disko/archive/${commit}.tar.gz";
# replace this with an actual hash
sha256 = "0000000000000000000000000000000000000000000000000000";
}}/module.nix"
];
}
```
2023-09-15 08:56:40 +03:00
</details>
## Using the NixOS module
```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";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}
```
2023-09-15 08:56:40 +03:00
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`.
2023-09-15 08:56:40 +03:00
disko will create the scripts `disko-create` and `disko-mount` which can be used
to create/mount the configured disk layout.