summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 3bfe83f2a04246f54f33790a3ffa14846e4c76fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
disko
=====

nix-powered automatic disk partitioning

Usage
=====

Master Boot Record
------------------
This is how your iso configuation may look like

/etc/nixos/configuration.nix
```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/`