zfs - hopefully set-up now?

This commit is contained in:
serenity-F 2024-09-26 16:51:15 +10:00
parent 57baff1611
commit fa4d3d8977
No known key found for this signature in database
5 changed files with 82 additions and 22 deletions

View file

@ -2,22 +2,33 @@
{
imports = [
## Include the results of the hardware scan.
## Import necessary flake modules
#"${builtins.fetchTarball "<flake module url>"}/module.nix"
## Include host specific options
./hardware.nix
#"${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix"
./network.nix
## Include core config options
../../config.nix
];
nix = {
#settings = {
#};
gc = {
## Every day, automatically collect garbage older than 10 days
## Automatically run 'nix-collect-garbage',
automatic = true;
## every day,
dates = "daily";
## and clear junk older than 3 days
options = "--delete-older-than 3d";
## No clue what this does lol.
persistent = true;
};
};

View file

@ -1,24 +1,15 @@
{ config, lib, pkgs, modulesPath, ... }:
let
latestZfsCompatibleLinuxPackages = lib.pipe pkgs.linuxKernel.packages [
builtins.attrValues
(builtins.filter (
kPkgs:
(builtins.tryEval kPkgs).success
&& kPkgs ? kernel
&& kPkgs.kernel.pname == "linux"
&& !kPkgs.zfs.meta.broken
))
(builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version)))
lib.last
];
in
{
imports = [
## Import necessary flake modules
#"${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix"
## Include results from the (non-existent) hardware scan
## as well as the host-specific hardware config options
(modulesPath + "/installer/scan/not-detected.nix")
## Commented out disko for now as I have broken it :c
## Disko commented out for now as we have "broken" it
#./disko.nix
];
@ -32,9 +23,9 @@ in
## Enable swap on luks
boot = {
kernelPackages = latestZfsCompatibleLinuxPackages;
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
supportedFilesystems = [ "btrfs" "xfs" "ntfs" ];
initrd = {
availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
kernelModules = [ ];
@ -64,8 +55,12 @@ in
};
## Trim to keep SSDs healthy-ish
services.fstrim.enable = true;
## Hardware-related services
services = {
## TRIM to keep SSDs healthy-ish
fstrim.enable = true;
};
#powerManagement = {
#enable = true;

View file

@ -0,0 +1,54 @@
## ZFS Support NixOS module
## temporary location while we figure out how ZFS works,
## eventually this will be embedded into the flake in a better way
{ config, lib, pkgs, ... }:
let
## This 'let' binding creates an attribute set
## called "LatestZfsLinux", which we can call as
## a package to specify when building our kernel.
latestZfsLinux = lib.pipe pkgs.linuxKernel.packages [
builtins.attrValues
(builtins.filter (
kPkgs:
(builtins.tryEval kPkgs).success
&& kPkgs ? kernel
&& kPkgs.kernel.pname == "linux"
&& !kPkgs.zfs.meta.broken
))
(builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version)))
lib.last
];
in
{
imports = [
];
## Enable zfs in kernel and boot
boot = {
kernelPackages = latestZfsLinux;
supportedFilesystems = [ "zfs" ];
zfs = {
#extraPools = [ "diska" "diskb" ];
forceImportRoot = false;
};
};
## Enable trim for ZFS SSDs
services = {
zfs = {
## Trim for SSSds with ZFS
trim.enable = true;
## Autoscrub data integrity ZFS service,
## more to be added soon
autoScrub = {
enable = true;
};
};
};
}