Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Lenovo t14 amd #908

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 122 additions & 105 deletions modules/disko/disko-ab-partitions.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,126 +18,143 @@
# - gp-storage : (50G) General purpose storage for some common insecure cases
# - recovery : (no quota) Recovery factory image is stored here
# - storagevm: (no quota) Dataset is meant to be used for StorageVM
{ pkgs, ... }:
{
# TODO Keep ZFS-related parts of the configuration here for now.
# This allows to have all config dependencies in one place and cleans
# other targets' configs from unnecessary components.
networking.hostId = "8425e349";
boot = {
initrd.availableKernelModules = [ "zfs" ];
supportedFilesystems = [ "zfs" ];
pkgs,
lib,
config,
...
}:
{

options = {
ghaf.imageBuilder.compression = lib.mkOption {
type = lib.types.enum [
"none"
"zstd"
];
default = "zstd";
};
};
disko = {
# 8GB is the recommeneded minimum for ZFS, so we are using this for VMs to avoid `cp` oom errors.
memSize = 17384;
imageBuilder = {
extraPostVM = ''
${pkgs.zstd}/bin/zstd --compress $out/*raw
rm $out/*raw
'';
config = {
# TODO Keep ZFS-related parts of the configuration here for now.
# This allows to have all config dependencies in one place and cleans
# other targets' configs from unnecessary components.
networking.hostId = "8425e349";
boot = {
initrd.availableKernelModules = [ "zfs" ];
supportedFilesystems = [ "zfs" ];
};
devices = {
disk.disk1 = {
type = "disk";
imageSize = "60G";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
priority = 1; # Needs to be first partition
};
esp = {
name = "ESP";
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"umask=0077"
"nofail"
];
disko = {
# 8GB is the recommeneded minimum for ZFS, so we are using this for VMs to avoid `cp` oom errors.
memSize = 17384;
imageBuilder = {
extraPostVM = lib.mkIf (config.ghaf.imageBuilder.compression == "zstd") ''
${pkgs.zstd}/bin/zstd --compress $out/*raw
rm $out/*raw
'';
};
devices = {
disk.disk1 = {
type = "disk";
imageSize = "60G";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
priority = 1; # Needs to be first partition
};
};
swap = {
size = "38G";
type = "8200";
content = {
type = "swap";
resumeDevice = true; # resume from hiberation from this device
# TODO: remove when LUKS is enabled
#randomEncryption = true;
esp = {
name = "ESP";
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"umask=0077"
"nofail"
];
};
};
};
zfs_1 = {
size = "100%";
content = {
type = "zfs";
pool = "zfspool";
swap = {
size = "38G";
type = "8200";
content = {
type = "swap";
resumeDevice = true; # resume from hiberation from this device
# TODO: remove when LUKS is enabled
#randomEncryption = true;
};
};
zfs_1 = {
size = "100%";
content = {
type = "zfs";
pool = "zfspool";
};
};
};
};
};
};
zpool = {
zfspool = {
type = "zpool";
rootFsOptions = {
mountpoint = "none";
acltype = "posixacl";
compression = "lz4";
xattr = "sa";
};
# `ashift=12` optimizes alignment for 4K sector size.
# Since this is an generic image and people might upgrade from one nvme device to another,
# we should make sure it runs well on these devices, also in theory 512B would work with less.
# This trades off some space overhead for overall better performance on 4k devices.
options.ashift = "12";
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
options = {
zpool = {
zfspool = {
type = "zpool";
rootFsOptions = {
mountpoint = "none";
acltype = "posixacl";
compression = "lz4";
xattr = "sa";
};
# `ashift=12` optimizes alignment for 4K sector size.
# Since this is an generic image and people might upgrade from one nvme device to another,
# we should make sure it runs well on these devices, also in theory 512B would work with less.
# This trades off some space overhead for overall better performance on 4k devices.
options.ashift = "12";
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
quota = "30G";
options = {
mountpoint = "/";
quota = "30G";
};
};
};
"vm_storage" = {
type = "zfs_fs";
options = {
mountpoint = "/vm_storage";
quota = "30G";
"vm_storage" = {
type = "zfs_fs";
options = {
mountpoint = "/vm_storage";
quota = "30G";
};
};
};
"reserved" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "10G";
"reserved" = {
type = "zfs_fs";
options = {
mountpoint = "none";
quota = "10G";
};
};
};
"gp_storage" = {
type = "zfs_fs";
options = {
mountpoint = "/gp_storage";
quota = "50G";
"gp_storage" = {
type = "zfs_fs";
options = {
mountpoint = "/gp_storage";
quota = "50G";
};
};
};
"recovery" = {
type = "zfs_fs";
options = {
mountpoint = "none";
"recovery" = {
type = "zfs_fs";
options = {
mountpoint = "none";
};
};
};
"storagevm" = {
type = "zfs_fs";
options = {
mountpoint = "/storagevm";
"storagevm" = {
type = "zfs_fs";
options = {
mountpoint = "/storagevm";
};
};
};
};
Expand Down
Loading
Loading