blob: 01c65e987e97037cae0d482a4d73e9bb4acb47d9 (
plain) (
blame)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
{
config,
lib,
pkgs,
...
}: let
cfg = config.sils.disks;
defaultMountOptions = [
"noatime" # should have some performance upsides, and I don't use it anyways
"lazytime" # make time changes in memory
];
in {
options.sils.disks = {
enable = lib.mkEnableOption "disk setup with disko";
disk = lib.mkOption {
type = lib.types.path;
example = lib.literalExpression "/dev/disk/by-uuid/0442cb6d-f13a-4635-b487-fa76189774c5";
description = "The disk used for installing the OS.";
};
#swap = {
# uuid = lib.mkOption {
# type = lib.types.str;
# example = lib.literalExpression "d1d20ae7-3d8a-44da-86da-677dbbb10c89";
# description = "The uuid of the swapfile";
# };
# resumeOffset = lib.mkOption {
# type = lib.types.str;
# example = lib.literalExpression "134324224";
# description = "The resume offset of the swapfile";
# };
#};
};
config = lib.mkIf cfg.enable {
disko.devices = {
disk = {
main = {
device = cfg.disk;
content = {
type = "gpt";
partitions = {
root = {
size = "100%";
name = "root";
content = {
type = "luks";
name = "cryptroot";
extraOpenArgs = ["--allow-discards"];
content = {
type = "btrfs";
extraArgs = ["-f" "--label nixos"]; # Override existing partitions
subvolumes = {
"root" = {
mountpoint = "/";
mountOptions = defaultMountOptions;
};
"nix" = {
mountpoint = "/nix";
mountOptions = defaultMountOptions;
};
"persistent-storage" = {
mountpoint = "/srv";
mountOptions = defaultMountOptions;
};
"persistent-storage@snapshots" = {
mountpoint = "/srv/.snapshots";
mountOptions = defaultMountOptions;
};
"swap" = {
mountpoint = "/swap";
mountOptions = defaultMountOptions;
};
"home" = {
mountpoint = "/home";
mountOptions = defaultMountOptions;
};
};
};
};
};
boot = {
type = "EF00";
size = "512M";
name = "boot";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
};
};
};
};
nodev = {
"/tmp" = {
fsType = "tmpfs";
mountOptions = ["defaults" "size=10G" "mode=755"];
};
};
};
fileSystems = {
"/srv" = {
neededForBoot = true;
};
"/swap" = {
neededForBoot = true;
};
};
swapDevices = [
#{
# device = "/swap/swapfile";
# priority = 1; # lower than zramSwap, just in case
# # size = 2048; # TODO: can nixos create a btrfs swapfile correctly?
#}
];
boot = {
kernelParams = [
#"resume_offset=${cfg.swap.resumeOffset}"
];
#resumeDevice = "/dev/disk/by-uuid/${cfg.swap.uuid}";
};
};
}
|