This commit is contained in:
mjallen18
2025-08-18 20:54:03 -05:00
parent 2623efc997
commit 05affb6b1f
3 changed files with 65 additions and 79 deletions

11
flake.lock generated
View File

@@ -180,16 +180,15 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1742690494, "lastModified": 1755519972,
"narHash": "sha256-SFacEbSRMoTyWG5VXh4ieofJGge+cLq9lH8ifB+zjBg=", "narHash": "sha256-bU4nqi3IpsUZJeyS8Jk85ytlX61i4b0KCxXX9YcOgVc=",
"owner": "nvmd", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "9dc58d4d49c9f74623a06e2fc20cdfd8bb3cbe8b", "rev": "4073ff2f481f9ef3501678ff479ed81402caae6d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nvmd", "owner": "nix-community",
"ref": "gpt-attrs",
"repo": "disko", "repo": "disko",
"type": "github" "type": "github"
} }

View File

@@ -43,8 +43,8 @@
disko = { disko = {
# the fork is needed for partition attributes support # the fork is needed for partition attributes support
url = "github:nvmd/disko/gpt-attrs"; # url = "github:nvmd/disko/gpt-attrs";
# url = "github:nix-community/disko"; url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };

View File

@@ -1,95 +1,82 @@
{ {
config,
lib, lib,
system, system,
namespace,
... ...
}: }:
let let
cfg = config.${namespace}.hardware.disko;
isArm = builtins.match "aarch64*" system != null; isArm = builtins.match "aarch64*" system != null;
rootDisk = "/dev/nvme0n1"; rootDisk = "/dev/nvme0n1";
in in
{ {
imports = [ ../options.nix ]; imports = [ ../options.nix ];
config = lib.mkIf (!isArm) {
config = lib.mkIf (cfg.enable && !isArm) {
disko.devices = { disko.devices = {
nodev."/" = { nodev."/" = {
fsType = "tmpfs"; fsType = "tmpfs";
mountOptions = [ mountOptions = [
"mode=755" "mode=755"
"defaults" "defaults"
"size=25%" "size=2G"
]; ];
}; };
# root disk setup disk = {
disk.main = { main = {
type = "disk"; device = rootDisk;
device = rootDisk; type = "disk";
imageSize = "32G"; imageSize = "15G";
content = { content = {
type = "gpt"; type = "gpt";
# specify partitions partitions = {
partitions = { ESP = {
# /boot type = "EF00";
ESP = { size = "100M";
priority = 1; content = {
name = "ESP"; type = "filesystem";
start = "1M"; format = "vfat";
end = "1G"; mountpoint = "/boot";
type = "EF00"; mountOptions = [ "umask=0077" ];
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
name = "btrfs-root";
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
"home" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/home";
};
"root" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/root";
};
"nix" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/nix";
};
"etc" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/etc";
};
"log" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/var/log";
};
}; };
}; };
root = {
size = "100%";
content = {
type = "bcachefs";
# This refers to a filesystem in the `bcachefs_filesystems` attrset below.
filesystem = "mounted_subvolumes_in_multi";
label = "ssd.ssd1";
extraFormatArgs = [
"--discard"
];
};
};
};
};
};
};
bcachefs_filesystems = {
mounted_subvolumes_in_multi = {
type = "bcachefs_filesystem";
# passwordFile = "/etc/nixos/pool.jwe";
extraFormatArgs = [
"--compression=zstd"
];
subvolumes = {
"subvolumes/root" = {
mountpoint = "/root";
};
"subvolumes/home" = {
mountpoint = "/home";
};
"subvolumes/nix" = {
mountpoint = "/nix";
};
"subvolumes/etc" = {
mountpoint = "/etc";
};
"subvolumes/log" = {
mountpoint = "/var/log";
}; };
}; };
}; };