Modules: replace Disko module with homegrown filesystems module
This commit is contained in:
parent
84885450a2
commit
5949038b15
|
@ -30,7 +30,7 @@ mount -o subvol=@ $root_drive /mnt
|
|||
mkdir -p /mnt/{boot,home,var/log,nix,swap}
|
||||
mount $boot_drive /mnt/boot
|
||||
mount -o subvol=@home $root_drive /mnt/home
|
||||
mount -o subvol=@log $root_drive /var/log
|
||||
mount -o subvol=@log $root_drive /mnt/var/log
|
||||
mount -o subvol=@nix $root_drive /mnt/nix
|
||||
mount -o subvol=@swap $root_drive /mnt/swap
|
||||
|
||||
|
|
21
flake.lock
21
flake.lock
|
@ -21,26 +21,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719864345,
|
||||
"narHash": "sha256-e4Pw+30vFAxuvkSTaTypd9zYemB/QlWcH186dsGT+Ms=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "544a80a69d6e2da04e4df7ec8210a858de8c7533",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -359,7 +339,6 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"disko": "disko",
|
||||
"home-manager": "home-manager",
|
||||
"lanzaboote": "lanzaboote",
|
||||
"lix-module": "lix-module",
|
||||
|
|
|
@ -37,18 +37,11 @@
|
|||
url = "git+file:./nix-secrets";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Disko support https://github.com/nix-community/disko
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{
|
||||
self,
|
||||
disko,
|
||||
home-manager,
|
||||
lanzaboote,
|
||||
lix-module,
|
||||
|
@ -70,7 +63,6 @@
|
|||
defaultModules = [
|
||||
./modules/autoimport.nix
|
||||
(import nix-secrets)
|
||||
disko.nixosModules.disko
|
||||
lix-module.nixosModules.default
|
||||
lanzaboote.nixosModules.lanzaboote
|
||||
nix-flatpak.nixosModules.nix-flatpak
|
||||
|
|
|
@ -7,12 +7,7 @@
|
|||
}:
|
||||
|
||||
let
|
||||
luksPartition = "/dev/disk/by-uuid/dfb4fc8f-e82b-43a1-91c1-a77acb6337cb";
|
||||
luksDevice = "9fdc521b-a037-4070-af47-f54da03675e4";
|
||||
standardMountOpts = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
luksUUID = "9fdc521b-a037-4070-af47-f54da03675e4";
|
||||
in
|
||||
{
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
|
@ -26,8 +21,8 @@ in
|
|||
"sd_mod"
|
||||
"sdhci_pci"
|
||||
];
|
||||
luks.devices."luks-${luksDevice}" = {
|
||||
device = "/dev/disk/by-uuid/${luksDevice}";
|
||||
luks.devices."luks-${luksUUID}" = {
|
||||
device = "/dev/disk/by-uuid/${luksUUID}";
|
||||
crypttabExtraOpts = [ "tpm2-device=auto" ]; # Enable TPM auto-unlocking
|
||||
};
|
||||
};
|
||||
|
@ -35,39 +30,18 @@ in
|
|||
extraModulePackages = [ ];
|
||||
};
|
||||
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = luksPartition;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@" ] ++ standardMountOpts;
|
||||
# Configure the main filesystem.
|
||||
aux.system.filesystem.btrfs = {
|
||||
enable = true;
|
||||
devices = {
|
||||
boot = "/dev/disk/by-uuid/FC20-D155";
|
||||
btrfs = "/dev/disk/by-uuid/${luksUUID}";
|
||||
};
|
||||
"/home" = {
|
||||
device = luksPartition;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@home" ] ++ standardMountOpts;
|
||||
};
|
||||
"/nix" = {
|
||||
device = luksPartition;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@nix" ] ++ standardMountOpts;
|
||||
};
|
||||
"/swap" = {
|
||||
device = luksPartition;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@swap" ];
|
||||
};
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/FC20-D155";
|
||||
fsType = "vfat";
|
||||
};
|
||||
};
|
||||
|
||||
swapDevices = [
|
||||
{
|
||||
device = "/swap/swapfile";
|
||||
swapFile = {
|
||||
enable = true;
|
||||
size = 16384;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.aux.system.disko;
|
||||
|
||||
standardMountOpts = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
in
|
||||
{
|
||||
options = {
|
||||
aux.system.disko = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "Enables Disko for disk & partition management.");
|
||||
primaryDiskID = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The ID of the disk to manage using Disko. If possible, use the World Wide Name (WWN), e.g `/dev/disk/by-id/nvme-eui.*`";
|
||||
default = "";
|
||||
};
|
||||
swapFile = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of swap files.");
|
||||
size = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The size of the swap file to create (defaults to 8G, or 8 gigabytes).";
|
||||
default = "8G";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Check for blank values
|
||||
assertions = [
|
||||
{
|
||||
assertion = (cfg.primaryDiskID != "");
|
||||
message = "aux.system.disko.primaryDiskID is not set. Please enter a valid disk ID.";
|
||||
}
|
||||
];
|
||||
# Disk management
|
||||
disko.enableConfig = true;
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = "/dev/disk/by-id/${cfg.primaryDiskID}";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
priority = 1;
|
||||
name = "ESP";
|
||||
label = "boot";
|
||||
size = "1G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
luks = {
|
||||
size = "100%";
|
||||
label = "nixos";
|
||||
content = {
|
||||
type = "luks";
|
||||
name = "cryptroot";
|
||||
settings = {
|
||||
allowDiscards = true;
|
||||
crypttabExtraOpts = lib.mkIf config.aux.system.bootloader.tpm2.enable [ "tpm2-device=auto" ];
|
||||
};
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ]; # Override existing partitions.
|
||||
# Unless otherwise specified, the subvolume name equals the mount name.
|
||||
subvolumes = {
|
||||
"/root" = {
|
||||
mountpoint = "/";
|
||||
mountOptions = standardMountOpts;
|
||||
};
|
||||
"/home" = {
|
||||
mountOptions = standardMountOpts;
|
||||
};
|
||||
"/nix" = {
|
||||
mountOptions = standardMountOpts;
|
||||
};
|
||||
"/swap" = lib.mkIf cfg.swapFile.enable {
|
||||
mountpoint = "/.swap";
|
||||
swap.swapfile.size = cfg.swapFile.size;
|
||||
};
|
||||
"/log" = {
|
||||
mountpoint = "/var/log";
|
||||
mountOptions = standardMountOpts;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
93
modules/system/filesystem.nix
Normal file
93
modules/system/filesystem.nix
Normal file
|
@ -0,0 +1,93 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.aux.system.filesystem.btrfs;
|
||||
|
||||
standardMountOpts = [
|
||||
"compress=zstd"
|
||||
"discard=async"
|
||||
"noatime"
|
||||
];
|
||||
in
|
||||
{
|
||||
options = {
|
||||
aux.system.filesystem.btrfs = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "Enables standard BTRFS subvolumes and parameters.");
|
||||
devices = {
|
||||
boot = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The ID of your boot partition. Use /dev/disk/by-uuid for best results.";
|
||||
default = "";
|
||||
};
|
||||
btrfs = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The ID of your BTRFS partition. Use /dev/disk/by-uuid for best results.";
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
swapFile = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of a swap file.");
|
||||
size = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = "The size of the swap file to create in MB (defaults to 8192, or ~8 gigabytes).";
|
||||
default = 8192;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# Check for blank parameters
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.devices.btrfs != "";
|
||||
message = "Please specify a BTRFS partition to use as a filesystem.";
|
||||
}
|
||||
{
|
||||
assertion = cfg.devices.boot != "";
|
||||
message = "Please specify a boot partition to use as a filesystem.";
|
||||
}
|
||||
];
|
||||
fileSystems =
|
||||
{
|
||||
"/" = {
|
||||
device = cfg.devices.btrfs;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@" ] ++ standardMountOpts;
|
||||
};
|
||||
"/boot" = {
|
||||
device = cfg.devices.boot;
|
||||
fsType = "vfat";
|
||||
};
|
||||
"/home" = {
|
||||
device = cfg.devices.btrfs;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@home" ] ++ standardMountOpts;
|
||||
};
|
||||
"/var/log" = {
|
||||
device = cfg.devices.btrfs;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@log" ] ++ standardMountOpts;
|
||||
};
|
||||
"/nix" = {
|
||||
device = cfg.devices.btrfs;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@nix" ] ++ standardMountOpts;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs cfg.swapFile.enable {
|
||||
"/swap" = {
|
||||
device = cfg.devices.btrfs;
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@swap" ];
|
||||
};
|
||||
};
|
||||
|
||||
swapDevices = lib.mkIf cfg.swapFile.enable [
|
||||
{
|
||||
device = "/swap/swapfile";
|
||||
size = cfg.swapFile.size;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue