nixberry: disko

This commit is contained in:
Christoph Hollizeck 2025-11-22 14:32:34 +01:00
parent 9521f7f7fd
commit 87dab6d253
Signed by: Daholli
GPG key ID: 249300664F2AF2C7
6 changed files with 307 additions and 83 deletions

View file

@ -11,7 +11,7 @@
username = "cholli";
in
{
imports = [ inputs.nix-ld.nixosModules.nix-ld ];
# imports = [ inputs.nix-ld.nixosModules.nix-ld ];
environment.systemPackages = with pkgs; [
nixfmt-rfc-style

View file

@ -20,11 +20,15 @@ in
{
nixpkgs = {
config.allowUnfree = true;
crossSystem = lib.mkIf (pkgs.stdenv.buildPlatform.system != "aarch64-linux") (
lib.systems.elaborate "aarch64-linux"
);
};
# hack
# hack, homemanager needs it
environment.systemPackages = [ pkgs.dconf ];
# build failure
programs.nix-ld.enable = false;
imports =
@ -147,7 +151,7 @@ in
};
services.home-assistant = {
enable = true;
enable = false;
configWritable = true;
extraComponents = [
"default_config"
@ -224,20 +228,5 @@ in
};
openFirewall = true;
};
fileSystems."/" = {
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
fsType = "ext4";
};
fileSystems."/boot/firmware" = {
device = "/dev/disk/by-uuid/2178-694E";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
};
};
}

View file

@ -0,0 +1,224 @@
{
flake.modules.nixos."hosts/nixberry" =
{
inputs,
lib,
...
}:
let
firmwarePartition = lib.recursiveUpdate {
# label = "FIRMWARE";
priority = 1;
type = "0700"; # Microsoft basic data
attributes = [
0 # Required Partition
];
size = "1024M";
content = {
type = "filesystem";
format = "vfat";
# mountpoint = "/boot/firmware";
mountOptions = [
"noatime"
"noauto"
"x-systemd.automount"
"x-systemd.idle-timeout=1min"
];
};
};
espPartition = lib.recursiveUpdate {
# label = "ESP";
type = "EF00"; # EFI System Partition (ESP)
attributes = [
2 # Legacy BIOS Bootable, for U-Boot to find extlinux config
];
size = "1024M";
content = {
type = "filesystem";
format = "vfat";
# mountpoint = "/boot";
mountOptions = [
"noatime"
"noauto"
"x-systemd.automount"
"x-systemd.idle-timeout=1min"
"umask=0077"
];
};
};
in
{
imports = [ inputs.disko.nixosModules.disko ];
boot.supportedFilesystems = [ "zfs" ];
networking.hostId = "8425e349";
services.zfs.autoScrub.enable = true;
services.zfs.trim.enable = true;
disko.devices = {
disk = {
ssd = {
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
};
main = {
device = "/dev/mmcblk0";
content = {
type = "gpt";
partitions = {
FIRMWARE = firmwarePartition {
label = "FIRMWARE";
content.mountpoint = "/boot/firmware";
};
ESP = espPartition {
label = "ESP";
content.mountpoint = "/boot";
};
# Swap Partition
swap = {
size = "8G";
label = "swap";
content = {
type = "swap";
discardPolicy = "both";
resumeDevice = true;
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "rpool"; # zroot
};
};
};
};
};
};
zpool = {
rpool = {
type = "zpool";
options = {
ashift = "12";
autotrim = "on"; # see also services.zfs.trim.enable
};
rootFsOptions = {
"com.sun:auto-snapshot" = "false";
# https://jrs-s.net/2018/08/17/zfs-tuning-cheat-sheet/
compression = "lz4";
atime = "off";
xattr = "sa";
acltype = "posixacl";
# https://rubenerd.com/forgetting-to-set-utf-normalisation-on-a-zfs-pool/
normalization = "formD";
dnodesize = "auto";
mountpoint = "none";
canmount = "off";
};
postCreateHook =
let
poolName = "rpool";
in
"zfs list -t snapshot -H -o name | grep -E '^${poolName}@blank$' || zfs snapshot ${poolName}@blank";
datasets = {
# stuff which can be recomputed/easily redownloaded, e.g. nix store
local = {
type = "zfs_fs";
options.mountpoint = "none";
};
"local/nix" = {
type = "zfs_fs";
options = {
reservation = "128M";
mountpoint = "legacy"; # to manage "with traditional tools"
};
mountpoint = "/nix"; # nixos configuration mountpoint
};
# _system_ data
system = {
type = "zfs_fs";
options = {
mountpoint = "none";
};
};
"system/root" = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
};
mountpoint = "/";
};
"system/var" = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
};
mountpoint = "/var";
};
# _user_ and _user service_ data. safest, long retention policy
safe = {
type = "zfs_fs";
options = {
copies = "2";
mountpoint = "none";
};
};
"safe/home" = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
};
mountpoint = "/home";
};
"safe/storage" = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
"com.sun:auto-snapshot" = "true";
};
mountpoint = "/storage";
};
"safe/var/lib" = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
};
mountpoint = "/var/lib";
};
};
};
};
};
};
}

View file

@ -13,13 +13,19 @@ in
...
}:
{
nixpkgs.config.allowUnfree = true;
nixpkgs = {
config.allowUnfree = true;
};
# Enable binfmt emulation.
boot.binfmt.emulatedSystems = [
"aarch64-linux"
];
environment.systemPackages = with pkgs; [
teamviewer
teams-for-linux
pyfa
obsidian
diebahn