mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
disko setup for gerg-desktop Thanks Lily!
This commit is contained in:
parent
ac70f98277
commit
0fce2524d7
6 changed files with 264 additions and 247 deletions
|
|
@ -10,8 +10,9 @@ inputs: {
|
|||
(import ./vfio.nix inputs)
|
||||
(import ./parrot.nix inputs)
|
||||
(import ./spicetify.nix inputs)
|
||||
(import ./zfs inputs)
|
||||
(import ./zfs.nix inputs)
|
||||
(import ./containers inputs)
|
||||
(import ./disko.nix inputs)
|
||||
];
|
||||
|
||||
system.stateVersion = "unstable";
|
||||
|
|
|
|||
210
systems/gerg-desktop/disko.nix
Normal file
210
systems/gerg-desktop/disko.nix
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
_: {
|
||||
disko.devices = {
|
||||
disk = {
|
||||
nvme0 = {
|
||||
type = "disk";
|
||||
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22";
|
||||
content = {
|
||||
type = "table";
|
||||
format = "gpt";
|
||||
partitions = [
|
||||
{
|
||||
name = "boot";
|
||||
type = "partition";
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
}
|
||||
{
|
||||
name = "ESP";
|
||||
type = "partition";
|
||||
start = "1M";
|
||||
end = "1G";
|
||||
bootable = true;
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N22";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zfsboot";
|
||||
type = "partition";
|
||||
start = "1G";
|
||||
end = "5G";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "bpool";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "swap";
|
||||
type = "partition";
|
||||
start = "5G";
|
||||
end = "21G";
|
||||
content = {
|
||||
type = "swap";
|
||||
randomEncryption = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zfsroot";
|
||||
type = "partition";
|
||||
start = "21G";
|
||||
end = "100%";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "rpool";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
nvme1 = {
|
||||
type = "disk";
|
||||
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
|
||||
content = {
|
||||
type = "table";
|
||||
format = "gpt";
|
||||
partitions = [
|
||||
{
|
||||
name = "BIOS";
|
||||
type = "partition";
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
}
|
||||
{
|
||||
name = "ESP";
|
||||
type = "partition";
|
||||
start = "1M";
|
||||
end = "1G";
|
||||
bootable = true;
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zfsboot";
|
||||
type = "partition";
|
||||
start = "1G";
|
||||
end = "5G";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "bpool";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "swap";
|
||||
type = "partition";
|
||||
start = "5G";
|
||||
end = "21G";
|
||||
content = {
|
||||
type = "swap";
|
||||
randomEncryption = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zfsroot";
|
||||
type = "partition";
|
||||
start = "21G";
|
||||
end = "100%";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "rpool";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
zpool = {
|
||||
rpool = {
|
||||
type = "zpool";
|
||||
mode = "mirror";
|
||||
rootFsOptions = {
|
||||
acltype = "posixacl";
|
||||
canmount = "off";
|
||||
compression = "zstd";
|
||||
dnodesize = "auto";
|
||||
normalization = "formD";
|
||||
relatime = "true";
|
||||
xattr = "sa";
|
||||
};
|
||||
options = {
|
||||
ashift = "12";
|
||||
autotrim = "on";
|
||||
};
|
||||
datasets = {
|
||||
"nixos" = {
|
||||
zfs_type = "filesystem";
|
||||
options = {
|
||||
canmount = "off";
|
||||
encryption = "on";
|
||||
keyformat = "passphrase";
|
||||
keylocation = "prompt";
|
||||
};
|
||||
};
|
||||
|
||||
"nixos/root" = {
|
||||
zfs_type = "filesystem";
|
||||
options.mountpoint = "legacy";
|
||||
mountpoint = "/";
|
||||
};
|
||||
|
||||
"nixos/home" = {
|
||||
zfs_type = "filesystem";
|
||||
options.mountpoint = "legacy";
|
||||
mountpoint = "/home";
|
||||
};
|
||||
"nixos/var" = {
|
||||
zfs_type = "filesystem";
|
||||
options.mountpoint = "legacy";
|
||||
mountpoint = "/var";
|
||||
};
|
||||
"nixos/var/log" = {
|
||||
zfs_type = "filesystem";
|
||||
options.mountpoint = "legacy";
|
||||
mountpoint = "/var/log";
|
||||
};
|
||||
"nixos/var/lib" = {
|
||||
zfs_type = "filesystem";
|
||||
options.mountpoint = "legacy";
|
||||
mountpoint = "/var/lib";
|
||||
};
|
||||
};
|
||||
};
|
||||
bpool = {
|
||||
type = "zpool";
|
||||
mode = "mirror";
|
||||
rootFsOptions = {
|
||||
acltype = "posixacl";
|
||||
canmount = "off";
|
||||
compression = "lz4";
|
||||
devices = "off";
|
||||
normalization = "formD";
|
||||
relatime = "on";
|
||||
xattr = "sa";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
|
||||
options = {
|
||||
compatibility = "grub2";
|
||||
ashift = "12";
|
||||
autotrim = "on";
|
||||
};
|
||||
datasets = {
|
||||
"nixos/root" = {
|
||||
zfs_type = "filesystem";
|
||||
options.mountpoint = "legacy";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
52
systems/gerg-desktop/zfs.nix
Normal file
52
systems/gerg-desktop/zfs.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
_: {
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
boot = {
|
||||
zfs = {
|
||||
devNodes = "/dev/disk/by-id/";
|
||||
forceImportAll = true;
|
||||
};
|
||||
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||
kernelParams = ["nohibernate" "zfs.zfs_arc_max=17179869184"];
|
||||
supportedFilesystems = ["zfs" "vfat"];
|
||||
initrd = {
|
||||
kernelModules = ["dm_mod"];
|
||||
availableKernelModules = ["hid_generic"];
|
||||
};
|
||||
plymouth.enable = false;
|
||||
loader = {
|
||||
timeout = lib.mkForce 10;
|
||||
generationsDir.copyKernels = true;
|
||||
|
||||
#override defaults
|
||||
systemd-boot.enable = false;
|
||||
efi.canTouchEfiVariables = false;
|
||||
|
||||
grub = {
|
||||
enable = true;
|
||||
efiInstallAsRemovable = true;
|
||||
version = 2;
|
||||
copyKernels = true;
|
||||
efiSupport = true;
|
||||
zfsSupport = true;
|
||||
mirroredBoots = [
|
||||
{
|
||||
path = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
|
||||
devices = ["/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E"];
|
||||
}
|
||||
{
|
||||
path = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N22";
|
||||
devices = ["/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22"];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
systemd.services.zfs-mount.enable = false;
|
||||
services.zfs = {
|
||||
autoScrub.enable = true;
|
||||
trim.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
_: {config, ...}: {
|
||||
boot = {
|
||||
zfs.devNodes = "/dev/disk/by-id/";
|
||||
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||
kernelParams = ["nohibernate" "zfs.zfs_arc_max=17179869184"];
|
||||
supportedFilesystems = ["zfs" "vfat"];
|
||||
initrd = {
|
||||
kernelModules = ["dm_mod"];
|
||||
availableKernelModules = ["hid_generic"];
|
||||
};
|
||||
plymouth.enable = false;
|
||||
loader = {
|
||||
generationsDir.copyKernels = true;
|
||||
|
||||
#override defaults
|
||||
systemd-boot.enable = false;
|
||||
efi.canTouchEfiVariables = false;
|
||||
|
||||
grub = {
|
||||
enable = true;
|
||||
efiInstallAsRemovable = true;
|
||||
version = 2;
|
||||
copyKernels = true;
|
||||
efiSupport = true;
|
||||
zfsSupport = true;
|
||||
mirroredBoots = [
|
||||
{
|
||||
path = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
|
||||
devices = ["/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E"];
|
||||
}
|
||||
{
|
||||
path = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N22";
|
||||
devices = ["/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22"];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
systemd.services.zfs-mount.enable = false;
|
||||
services.zfs = {
|
||||
autoScrub.enable = true;
|
||||
trim.enable = true;
|
||||
};
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "rpool/nixos/root";
|
||||
fsType = "zfs";
|
||||
options = ["X-mount.mkdir"];
|
||||
};
|
||||
|
||||
"/home" = {
|
||||
device = "rpool/nixos/home";
|
||||
fsType = "zfs";
|
||||
options = ["X-mount.mkdir"];
|
||||
};
|
||||
|
||||
"/var" = {
|
||||
device = "rpool/nixos/var";
|
||||
fsType = "zfs";
|
||||
options = ["X-mount.mkdir"];
|
||||
};
|
||||
|
||||
"/var/lib" = {
|
||||
device = "rpool/nixos/var/lib";
|
||||
fsType = "zfs";
|
||||
options = ["X-mount.mkdir"];
|
||||
};
|
||||
|
||||
"/var/log" = {
|
||||
device = "rpool/nixos/var/log";
|
||||
fsType = "zfs";
|
||||
options = ["X-mount.mkdir"];
|
||||
};
|
||||
|
||||
"/boot" = {
|
||||
device = "bpool/nixos/root";
|
||||
fsType = "zfs";
|
||||
options = ["X-mount.mkdir"];
|
||||
};
|
||||
|
||||
"/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N0E" = {
|
||||
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E-part2";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"X-mount.mkdir"
|
||||
"x-systemd.idle-timout=1min"
|
||||
"x-systemd.automount"
|
||||
"noauto"
|
||||
"nofail"
|
||||
];
|
||||
};
|
||||
"/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N22" = {
|
||||
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22-part2";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"X-mount.mkdir"
|
||||
"x-systemd.idle-timout=1min"
|
||||
"x-systemd.automount"
|
||||
"noauto"
|
||||
"nofail"
|
||||
];
|
||||
};
|
||||
};
|
||||
swapDevices = [
|
||||
{
|
||||
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E-part4";
|
||||
discardPolicy = "both";
|
||||
randomEncryption = {
|
||||
enable = true;
|
||||
allowDiscards = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22-part4";
|
||||
discardPolicy = "both";
|
||||
randomEncryption = {
|
||||
enable = true;
|
||||
allowDiscards = true;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/sh
|
||||
DISK='/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22 /dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E'
|
||||
set -e
|
||||
zpool import -f rpool
|
||||
zpool import -f bpool
|
||||
zfs load-key rpool/nixos
|
||||
mount -t zfs rpool/nixos/root /mnt/
|
||||
|
||||
mount -t zfs rpool/nixos/home /mnt/home
|
||||
|
||||
mount -t zfs rpool/nixos/var /mnt/var
|
||||
mount -t zfs rpool/nixos/var/lib /mnt/var/lib
|
||||
mount -t zfs rpool/nixos/var/log /mnt/var/log
|
||||
|
||||
mount -t zfs bpool/nixos/root /mnt/boot
|
||||
|
||||
for i in ${DISK}; do
|
||||
mount -t vfat ${i}-part2 /mnt/boot/efis/${i##*/}
|
||||
done
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
#!/bin/sh
|
||||
DISK='/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22 /dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E'
|
||||
|
||||
INST_PARTSIZE_SWAP=16
|
||||
INST_PARTSIZE_RPOOL=
|
||||
|
||||
set -e
|
||||
|
||||
for i in ${DISK}; do
|
||||
|
||||
blkdiscard -f $i
|
||||
|
||||
sgdisk --zap-all $i
|
||||
sgdisk -a1 -n1:24K:+1000K -t1:EF02 $i
|
||||
sgdisk -n2:01M:+1G -t2:EF00 $i
|
||||
sgdisk -n3:0:+4G -t3:BE00 $i
|
||||
sgdisk -n4:0:+${INST_PARTSIZE_SWAP}G -t4:8200 $i
|
||||
|
||||
if test -z $INST_PARTSIZE_RPOOL; then
|
||||
sgdisk -n5:0:0 -t5:BF00 $i
|
||||
else
|
||||
sgdisk -n5:0:+${INST_PARTSIZE_RPOOL}G -t5:BF00 $i
|
||||
fi
|
||||
|
||||
sync && udevadm settle && sleep 3
|
||||
|
||||
cryptsetup open --type plain --key-file /dev/random $i-part4 ${i##*/}-part4
|
||||
mkswap /dev/mapper/${i##*/}-part4
|
||||
swapon /dev/mapper/${i##*/}-part4
|
||||
done
|
||||
|
||||
zpool create \
|
||||
-o compatibility=grub2 \
|
||||
-o ashift=12 \
|
||||
-o autotrim=on \
|
||||
-O acltype=posixacl \
|
||||
-O canmount=off \
|
||||
-O compression=lz4 \
|
||||
-O devices=off \
|
||||
-O normalization=formD \
|
||||
-O relatime=on \
|
||||
-O xattr=sa \
|
||||
-O mountpoint=/boot \
|
||||
-R /mnt \
|
||||
bpool \
|
||||
mirror \
|
||||
$(for i in ${DISK}; do
|
||||
printf "$i-part3 ";
|
||||
done)
|
||||
|
||||
zpool create \
|
||||
-o ashift=12 \
|
||||
-o autotrim=on \
|
||||
-R /mnt \
|
||||
-O acltype=posixacl \
|
||||
-O canmount=off \
|
||||
-O compression=zstd \
|
||||
-O dnodesize=auto \
|
||||
-O normalization=formD \
|
||||
-O relatime=on \
|
||||
-O xattr=sa \
|
||||
-O mountpoint=/ \
|
||||
rpool \
|
||||
mirror \
|
||||
$(for i in ${DISK}; do
|
||||
printf "$i-part5 ";
|
||||
done)
|
||||
|
||||
zfs create \
|
||||
-o canmount=off \
|
||||
-o mountpoint=none \
|
||||
-o encryption=on \
|
||||
-o keylocation=prompt \
|
||||
-o keyformat=passphrase \
|
||||
rpool/nixos
|
||||
|
||||
zfs create -o mountpoint=legacy rpool/nixos/root
|
||||
mount -t zfs rpool/nixos/root /mnt/
|
||||
|
||||
zfs create -o mountpoint=legacy rpool/nixos/home
|
||||
mkdir /mnt/home
|
||||
mount -t zfs rpool/nixos/home /mnt/home
|
||||
|
||||
zfs create -o mountpoint=legacy rpool/nixos/var
|
||||
mkdir /mnt/var
|
||||
mount -t zfs rpool/nixos/var /mnt/var
|
||||
zfs create -o mountpoint=legacy rpool/nixos/var/lib
|
||||
mkdir /mnt/var/lib
|
||||
mount -t zfs rpool/nixos/var/lib /mnt/var/lib
|
||||
zfs create -o mountpoint=legacy rpool/nixos/var/log
|
||||
mkdir /mnt/var/log
|
||||
mount -t zfs rpool/nixos/var/log /mnt/var/log
|
||||
|
||||
zfs create -o mountpoint=none bpool/nixos
|
||||
zfs create -o mountpoint=legacy bpool/nixos/root
|
||||
mkdir /mnt/boot
|
||||
mount -t zfs bpool/nixos/root /mnt/boot
|
||||
zfs create -o mountpoint=legacy rpool/nixos/empty
|
||||
zfs snapshot rpool/nixos/empty@start
|
||||
|
||||
for i in ${DISK}; do
|
||||
mkfs.vfat -n EFI ${i}-part2
|
||||
mkdir -p /mnt/boot/efis/${i##*/}
|
||||
mount -t vfat ${i}-part2 /mnt/boot/efis/${i##*/}
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue