forked from c3d2/nix-config
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));
|
||||
|
||||
disko = {
|
||||
devices = lib.mkIf (cfg.disks != [ ]) (lib.head (map
|
||||
(disk:
|
||||
let
|
||||
diskName = if disk.name != "" then "-${disk.name}" else "";
|
||||
luksName = "crypt-${config.networking.hostName}${diskName}";
|
||||
rootSize = 200; # size of the zfs partition if inside of lvm
|
||||
vgName = "lvm-${config.networking.hostName}${diskName}";
|
||||
zfs = {
|
||||
size = if (!disk.withCeph) then "100%FREE" else "${toString rootSize}GiB";
|
||||
content = {
|
||||
pool = zfsName;
|
||||
type = "zfs";
|
||||
};
|
||||
disko.devices = lib.mkIf (cfg.disks != [ ]) (lib.head (map
|
||||
(disk:
|
||||
let
|
||||
diskName = if disk.name != "" then "-${disk.name}" else "";
|
||||
luksName = "crypt-${config.networking.hostName}${diskName}";
|
||||
rootSize = 200; # size of the zfs partition if inside of lvm
|
||||
vgName = "lvm-${config.networking.hostName}${diskName}";
|
||||
zfs = {
|
||||
size = if (!disk.withCeph) then "100%FREE" else "${toString rootSize}GiB";
|
||||
content = {
|
||||
pool = zfsName;
|
||||
type = "zfs";
|
||||
};
|
||||
zfsName = "${config.networking.hostName}${diskName}";
|
||||
in
|
||||
{
|
||||
disk.${disk.device} = {
|
||||
inherit (disk) device;
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "table";
|
||||
format = "gpt";
|
||||
partitions = lib.optional disk.withZfs
|
||||
{
|
||||
name = "ESP";
|
||||
start = "1MiB";
|
||||
end = "512MiB";
|
||||
bootable = true;
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
} ++ [
|
||||
{
|
||||
name = "root";
|
||||
start = if disk.withZfs then "512MiB" else "1MiB";
|
||||
end = "100%";
|
||||
part-type = "primary";
|
||||
content = lib.optionalAttrs disk.withLuks
|
||||
{
|
||||
type = "luks";
|
||||
name = luksName;
|
||||
# TODO: add password, otherwise prompt opens
|
||||
keyFile = "/$PWD/keyFile";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = vgName;
|
||||
};
|
||||
} // lib.optionalAttrs (!disk.withLuks) zfs.content;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
zfsName = "${config.networking.hostName}${diskName}";
|
||||
in
|
||||
{
|
||||
disk.${disk.device} = {
|
||||
inherit (disk) device;
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "table";
|
||||
format = "gpt";
|
||||
partitions = lib.optional disk.withZfs
|
||||
{
|
||||
name = "ESP";
|
||||
start = "1MiB";
|
||||
end = "512MiB";
|
||||
bootable = true;
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
} ++ [
|
||||
{
|
||||
name = "root";
|
||||
start = if disk.withZfs then "512MiB" else "1MiB";
|
||||
end = "100%";
|
||||
part-type = "primary";
|
||||
content = lib.optionalAttrs disk.withLuks
|
||||
{
|
||||
type = "luks";
|
||||
name = luksName;
|
||||
# TODO: add password, otherwise prompt opens
|
||||
keyFile = "/$PWD/keyFile";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = vgName;
|
||||
};
|
||||
} // lib.optionalAttrs (!disk.withLuks) zfs.content;
|
||||
}
|
||||
];
|
||||
};
|
||||
} // lib.optionalAttrs disk.withLuks {
|
||||
lvm_vg.${vgName} = {
|
||||
type = "lvm_vg";
|
||||
lvs = lib.optionalAttrs disk.withCeph {
|
||||
};
|
||||
} // lib.optionalAttrs disk.withLuks {
|
||||
lvm_vg.${vgName} = {
|
||||
type = "lvm_vg";
|
||||
lvs = lib.optionalAttrs disk.withCeph
|
||||
{
|
||||
ceph.size = "100%FREE";
|
||||
} // lib.optionalAttrs disk.withZfs { inherit zfs; };
|
||||
};
|
||||
} // {
|
||||
zpool.${zfsName} = {
|
||||
type = "zpool";
|
||||
mountpoint = "/";
|
||||
rootFsOptions.acltype = "posixacl";
|
||||
options = {
|
||||
ashift = "12";
|
||||
autotrim = "on";
|
||||
};
|
||||
} // {
|
||||
zpool.${zfsName} = {
|
||||
type = "zpool";
|
||||
mountpoint = null;
|
||||
rootFsOptions.acltype = "posixacl";
|
||||
options = {
|
||||
ashift = "12";
|
||||
autotrim = "on";
|
||||
};
|
||||
datasets =
|
||||
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";
|
||||
datasets =
|
||||
let
|
||||
dataset = mountpoint: {
|
||||
options = {
|
||||
canmount = "on";
|
||||
compression = "zstd";
|
||||
dnodesize = "auto";
|
||||
normalization = "formD";
|
||||
xattr = "sa";
|
||||
inherit mountpoint;
|
||||
};
|
||||
type = "zfs_fs";
|
||||
};
|
||||
};
|
||||
})
|
||||
cfg.disks));
|
||||
# we use our own hardware-configuration.nix
|
||||
enableConfig = false;
|
||||
};
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
cfg.disks));
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue