zfs - hopefully set-up now?
This commit is contained in:
parent
57baff1611
commit
fa4d3d8977
5 changed files with 82 additions and 22 deletions
|
|
@ -2,22 +2,33 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
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
|
./hardware.nix
|
||||||
#"${builtins.fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz"}/module.nix"
|
|
||||||
./network.nix
|
./network.nix
|
||||||
|
|
||||||
|
## Include core config options
|
||||||
../../config.nix
|
../../config.nix
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
|
|
||||||
#settings = {
|
#settings = {
|
||||||
#};
|
#};
|
||||||
|
|
||||||
gc = {
|
gc = {
|
||||||
## Every day, automatically collect garbage older than 10 days
|
## Automatically run 'nix-collect-garbage',
|
||||||
automatic = true;
|
automatic = true;
|
||||||
|
## every day,
|
||||||
dates = "daily";
|
dates = "daily";
|
||||||
|
## and clear junk older than 3 days
|
||||||
options = "--delete-older-than 3d";
|
options = "--delete-older-than 3d";
|
||||||
|
|
||||||
|
## No clue what this does lol.
|
||||||
persistent = true;
|
persistent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,15 @@
|
||||||
{ config, lib, pkgs, modulesPath, ... }:
|
{ 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 = [
|
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")
|
(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
|
#./disko.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -32,9 +23,9 @@ in
|
||||||
|
|
||||||
## Enable swap on luks
|
## Enable swap on luks
|
||||||
boot = {
|
boot = {
|
||||||
kernelPackages = latestZfsCompatibleLinuxPackages;
|
|
||||||
kernelModules = [ "kvm-intel" ];
|
kernelModules = [ "kvm-intel" ];
|
||||||
extraModulePackages = [ ];
|
extraModulePackages = [ ];
|
||||||
|
supportedFilesystems = [ "btrfs" "xfs" "ntfs" ];
|
||||||
initrd = {
|
initrd = {
|
||||||
availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
|
availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
|
||||||
kernelModules = [ ];
|
kernelModules = [ ];
|
||||||
|
|
@ -64,8 +55,12 @@ in
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
## Trim to keep SSDs healthy-ish
|
## Hardware-related services
|
||||||
services.fstrim.enable = true;
|
services = {
|
||||||
|
## TRIM to keep SSDs healthy-ish
|
||||||
|
fstrim.enable = true;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#powerManagement = {
|
#powerManagement = {
|
||||||
#enable = true;
|
#enable = true;
|
||||||
54
core/hosts/hades/hardware/zfs.nix
Normal file
54
core/hosts/hades/hardware/zfs.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue