feat: added zfs support
This commit is contained in:
parent
db2c498d9b
commit
771360aa93
2 changed files with 57 additions and 0 deletions
56
modules/features/programs/zfs.nix
Normal file
56
modules/features/programs/zfs.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
{ self, inputs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
flake.nixosModules.zfs-support =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
# matches kernel to latest with zfs support
|
||||||
|
# Black magic wizardry from https://wiki.nixos.org/wiki/ZFS
|
||||||
|
zfsCompatibleKernelPackages = lib.filterAttrs (
|
||||||
|
name: kernelPackages:
|
||||||
|
(builtins.match "linux_[0-9]+_[0-9]+" name) != null
|
||||||
|
&& (builtins.tryEval kernelPackages).success
|
||||||
|
&& (!kernelPackages.${config.boot.zfs.package.kernelModuleAttribute}.meta.broken)
|
||||||
|
) pkgs.linuxKernel.packages;
|
||||||
|
latestKernelPackage = lib.last (
|
||||||
|
lib.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version)) (
|
||||||
|
builtins.attrValues zfsCompatibleKernelPackages
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ inputs.home-manager.nixosModules.home-manager ];
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
# sets system to use latest zfs compatible kernel
|
||||||
|
kernelPackages = lib.mkForce latestKernelPackage;
|
||||||
|
# adds zfs support at boot
|
||||||
|
supportedFilesystems = [ "zfs" ];
|
||||||
|
|
||||||
|
# imports zfs pools on host device
|
||||||
|
zfs = {
|
||||||
|
extraPools = [ "orcus" ];
|
||||||
|
forceImportRoot = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# adds zfs to system packages
|
||||||
|
environment.systemPackages = with pkgs; [ zfs ];
|
||||||
|
|
||||||
|
# is this needed?
|
||||||
|
#networking.hostId = "603b0c8b";
|
||||||
|
|
||||||
|
# data integrity service
|
||||||
|
services.zfs.autoScrub = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
terminal
|
terminal
|
||||||
desktop
|
desktop
|
||||||
#multimedia
|
#multimedia
|
||||||
|
zfs
|
||||||
gaming
|
gaming
|
||||||
music
|
music
|
||||||
music-production
|
music-production
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue