modules: add disko partition module for common partition patterns
This commit is contained in:
parent
0f4a315658
commit
3dc3775a6c
5 changed files with 92 additions and 0 deletions
21
flake.lock
generated
21
flake.lock
generated
|
@ -61,6 +61,26 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"disko": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1732645828,
|
||||||
|
"narHash": "sha256-+4U2I2653JvPFxcux837ulwYS864QvEueIljUkwytsk=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "disko",
|
||||||
|
"rev": "869ba3a87486289a4197b52a6c9e7222edf00b3e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "disko",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -596,6 +616,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"catppuccin": "catppuccin",
|
"catppuccin": "catppuccin",
|
||||||
"colmena": "colmena",
|
"colmena": "colmena",
|
||||||
|
"disko": "disko",
|
||||||
"flake-utils": "flake-utils_2",
|
"flake-utils": "flake-utils_2",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"my-nixvim": "my-nixvim",
|
"my-nixvim": "my-nixvim",
|
||||||
|
|
|
@ -50,6 +50,11 @@
|
||||||
catppuccin = {
|
catppuccin = {
|
||||||
url = "github:catppuccin/nix";
|
url = "github:catppuccin/nix";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
disko = {
|
||||||
|
url = "github:nix-community/disko";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
|
@ -66,6 +71,7 @@
|
||||||
nix-vscode-extensions,
|
nix-vscode-extensions,
|
||||||
colmena,
|
colmena,
|
||||||
nix-index-database,
|
nix-index-database,
|
||||||
|
disko,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
46
modules/nixos/disk-partitions/btrfs.nix
Normal file
46
modules/nixos/disk-partitions/btrfs.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
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 = {
|
||||||
|
# Subvolume name is different from mountpoint
|
||||||
|
"/rootfs" = {
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
# Subvolume name is the same as the mountpoint
|
||||||
|
"/home" = {
|
||||||
|
mountOptions = [ "compress=zstd" ];
|
||||||
|
mountpoint = "/home";
|
||||||
|
};
|
||||||
|
# Parent is not mounted so the mountpoint must be set
|
||||||
|
"/nix" = {
|
||||||
|
mountOptions = [
|
||||||
|
"compress=zstd"
|
||||||
|
"noatime"
|
||||||
|
];
|
||||||
|
mountpoint = "/nix";
|
||||||
|
};
|
||||||
|
"/persistent" = {
|
||||||
|
mountOptions = [
|
||||||
|
"compress=zstd"
|
||||||
|
"noatime"
|
||||||
|
# Lots of dbs in /var/lib, let's disable cow
|
||||||
|
"nodatacow"
|
||||||
|
];
|
||||||
|
mountpoint = "/var/lib";
|
||||||
|
};
|
||||||
|
# Subvolume for the swapfile
|
||||||
|
"/swap" = {
|
||||||
|
mountpoint = "/.swapvol";
|
||||||
|
swap = {
|
||||||
|
swapfile.size = "2G";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mountpoint = "/partition-root";
|
||||||
|
};
|
||||||
|
}
|
15
modules/nixos/disk-partitions/default.nix
Normal file
15
modules/nixos/disk-partitions/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
diskPartitions = lib.mkOption {
|
||||||
|
type = lib.types.attrs;
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
diskPartitions = {
|
||||||
|
btrfs = import ./btrfs.nix;
|
||||||
|
grubMbr = import ./grub-mbr.nix;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
4
modules/nixos/disk-partitions/grub-mbr.nix
Normal file
4
modules/nixos/disk-partitions/grub-mbr.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
size = "1M";
|
||||||
|
type = "EF02"; # for grub MBR
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue