disko: use disko for config.fileSystems
because nixos-generate-config does not handle our complex setup :(
This commit is contained in:
parent
23a1aecaf5
commit
815a379ddb
|
@ -64,133 +64,130 @@ in
|
||||||
])
|
])
|
||||||
cfg.disks));
|
cfg.disks));
|
||||||
|
|
||||||
disko = {
|
disko.devices = lib.mkIf (cfg.disks != [ ]) (lib.head (map
|
||||||
devices = lib.mkIf (cfg.disks != [ ]) (lib.head (map
|
(disk:
|
||||||
(disk:
|
let
|
||||||
let
|
diskName = if disk.name != "" then "-${disk.name}" else "";
|
||||||
diskName = if disk.name != "" then "-${disk.name}" else "";
|
luksName = "crypt-${config.networking.hostName}${diskName}";
|
||||||
luksName = "crypt-${config.networking.hostName}${diskName}";
|
rootSize = 200; # size of the zfs partition if inside of lvm
|
||||||
rootSize = 200; # size of the zfs partition if inside of lvm
|
vgName = "lvm-${config.networking.hostName}${diskName}";
|
||||||
vgName = "lvm-${config.networking.hostName}${diskName}";
|
zfs = {
|
||||||
zfs = {
|
size = if (!disk.withCeph) then "100%FREE" else "${toString rootSize}GiB";
|
||||||
size = if (!disk.withCeph) then "100%FREE" else "${toString rootSize}GiB";
|
content = {
|
||||||
content = {
|
pool = zfsName;
|
||||||
pool = zfsName;
|
type = "zfs";
|
||||||
type = "zfs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
zfsName = "${config.networking.hostName}${diskName}";
|
};
|
||||||
in
|
zfsName = "${config.networking.hostName}${diskName}";
|
||||||
{
|
in
|
||||||
disk.${disk.device} = {
|
{
|
||||||
inherit (disk) device;
|
disk.${disk.device} = {
|
||||||
type = "disk";
|
inherit (disk) device;
|
||||||
content = {
|
type = "disk";
|
||||||
type = "table";
|
content = {
|
||||||
format = "gpt";
|
type = "table";
|
||||||
partitions = lib.optional disk.withZfs
|
format = "gpt";
|
||||||
{
|
partitions = lib.optional disk.withZfs
|
||||||
name = "ESP";
|
{
|
||||||
start = "1MiB";
|
name = "ESP";
|
||||||
end = "512MiB";
|
start = "1MiB";
|
||||||
bootable = true;
|
end = "512MiB";
|
||||||
content = {
|
bootable = true;
|
||||||
type = "filesystem";
|
content = {
|
||||||
format = "vfat";
|
type = "filesystem";
|
||||||
mountpoint = "/boot";
|
format = "vfat";
|
||||||
};
|
mountpoint = "/boot";
|
||||||
} ++ [
|
};
|
||||||
{
|
} ++ [
|
||||||
name = "root";
|
{
|
||||||
start = if disk.withZfs then "512MiB" else "1MiB";
|
name = "root";
|
||||||
end = "100%";
|
start = if disk.withZfs then "512MiB" else "1MiB";
|
||||||
part-type = "primary";
|
end = "100%";
|
||||||
content = lib.optionalAttrs disk.withLuks
|
part-type = "primary";
|
||||||
{
|
content = lib.optionalAttrs disk.withLuks
|
||||||
type = "luks";
|
{
|
||||||
name = luksName;
|
type = "luks";
|
||||||
# TODO: add password, otherwise prompt opens
|
name = luksName;
|
||||||
keyFile = "/$PWD/keyFile";
|
# TODO: add password, otherwise prompt opens
|
||||||
content = {
|
keyFile = "/$PWD/keyFile";
|
||||||
type = "lvm_pv";
|
content = {
|
||||||
vg = vgName;
|
type = "lvm_pv";
|
||||||
};
|
vg = vgName;
|
||||||
} // lib.optionalAttrs (!disk.withLuks) zfs.content;
|
};
|
||||||
}
|
} // lib.optionalAttrs (!disk.withLuks) zfs.content;
|
||||||
];
|
}
|
||||||
};
|
];
|
||||||
};
|
};
|
||||||
} // lib.optionalAttrs disk.withLuks {
|
};
|
||||||
lvm_vg.${vgName} = {
|
} // lib.optionalAttrs disk.withLuks {
|
||||||
type = "lvm_vg";
|
lvm_vg.${vgName} = {
|
||||||
lvs = lib.optionalAttrs disk.withCeph {
|
type = "lvm_vg";
|
||||||
|
lvs = lib.optionalAttrs disk.withCeph
|
||||||
|
{
|
||||||
ceph.size = "100%FREE";
|
ceph.size = "100%FREE";
|
||||||
} // lib.optionalAttrs disk.withZfs { inherit zfs; };
|
} // lib.optionalAttrs disk.withZfs { inherit zfs; };
|
||||||
|
};
|
||||||
|
} // {
|
||||||
|
zpool.${zfsName} = {
|
||||||
|
type = "zpool";
|
||||||
|
mountpoint = "/";
|
||||||
|
rootFsOptions.acltype = "posixacl";
|
||||||
|
options = {
|
||||||
|
ashift = "12";
|
||||||
|
autotrim = "on";
|
||||||
};
|
};
|
||||||
} // {
|
datasets =
|
||||||
zpool.${zfsName} = {
|
let
|
||||||
type = "zpool";
|
dataset = mountpoint: {
|
||||||
mountpoint = null;
|
options = {
|
||||||
rootFsOptions.acltype = "posixacl";
|
canmount = "on";
|
||||||
options = {
|
compression = "zstd";
|
||||||
ashift = "12";
|
dnodesize = "auto";
|
||||||
autotrim = "on";
|
normalization = "formD";
|
||||||
};
|
xattr = "sa";
|
||||||
datasets =
|
inherit mountpoint;
|
||||||
let
|
|
||||||
dataset = mountpoint: {
|
|
||||||
options = {
|
|
||||||
canmount = "on";
|
|
||||||
compression = "zstd";
|
|
||||||
dnodesize = "auto";
|
|
||||||
normalization = "formD";
|
|
||||||
xattr = "sa";
|
|
||||||
inherit mountpoint;
|
|
||||||
};
|
|
||||||
type = "zfs_fs";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
"data" = dataset "/";
|
|
||||||
"data/etc" = dataset "/etc";
|
|
||||||
"data/home" = dataset "/home";
|
|
||||||
"data/var" = dataset "/var";
|
|
||||||
# used by services.postgresqlBackup and later by restic
|
|
||||||
"data/var/backup" = dataset "/var/backup";
|
|
||||||
"data/var/lib" = dataset "/var/lib";
|
|
||||||
"data/var/log" = dataset "/var/log";
|
|
||||||
"nixos" = {
|
|
||||||
options = {
|
|
||||||
canmount = "off";
|
|
||||||
mountpoint = "none";
|
|
||||||
};
|
|
||||||
type = "zfs_fs";
|
|
||||||
};
|
|
||||||
"nixos/nix" = dataset "/nix";
|
|
||||||
"nixos/nix/store" = {
|
|
||||||
options = {
|
|
||||||
atime = "off";
|
|
||||||
canmount = "on";
|
|
||||||
mountpoint = "/nix/store";
|
|
||||||
};
|
|
||||||
type = "zfs_fs";
|
|
||||||
};
|
|
||||||
"nixos/nix/var" = dataset "/nix/var";
|
|
||||||
"reserved" = {
|
|
||||||
# zfs uses copy on write and requires some free space to delete files when the disk is completely filled
|
|
||||||
options = {
|
|
||||||
canmount = "off";
|
|
||||||
mountpoint = "none";
|
|
||||||
reservation = "5GiB";
|
|
||||||
};
|
|
||||||
type = "zfs_fs";
|
|
||||||
};
|
};
|
||||||
|
type = "zfs_fs";
|
||||||
};
|
};
|
||||||
};
|
in
|
||||||
})
|
{
|
||||||
cfg.disks));
|
"data" = dataset "/";
|
||||||
# we use our own hardware-configuration.nix
|
"data/etc" = dataset "/etc";
|
||||||
enableConfig = false;
|
"data/home" = dataset "/home";
|
||||||
};
|
"data/var" = dataset "/var";
|
||||||
|
# used by services.postgresqlBackup and later by restic
|
||||||
|
"data/var/backup" = dataset "/var/backup";
|
||||||
|
"data/var/lib" = dataset "/var/lib";
|
||||||
|
"data/var/log" = dataset "/var/log";
|
||||||
|
"nixos" = {
|
||||||
|
options = {
|
||||||
|
canmount = "off";
|
||||||
|
mountpoint = "none";
|
||||||
|
};
|
||||||
|
type = "zfs_fs";
|
||||||
|
};
|
||||||
|
"nixos/nix" = dataset "/nix";
|
||||||
|
"nixos/nix/store" = {
|
||||||
|
options = {
|
||||||
|
atime = "off";
|
||||||
|
canmount = "on";
|
||||||
|
mountpoint = "/nix/store";
|
||||||
|
};
|
||||||
|
type = "zfs_fs";
|
||||||
|
};
|
||||||
|
"nixos/nix/var" = dataset "/nix/var";
|
||||||
|
"reserved" = {
|
||||||
|
# zfs uses copy on write and requires some free space to delete files when the disk is completely filled
|
||||||
|
options = {
|
||||||
|
canmount = "off";
|
||||||
|
mountpoint = "none";
|
||||||
|
reservation = "5GiB";
|
||||||
|
};
|
||||||
|
type = "zfs_fs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
cfg.disks));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue