added zfs2.nix to test a repair for the breaking change from the latest flake.lock update

This commit is contained in:
serenity-F 2025-02-28 22:21:29 +10:00
parent b012ab1e3f
commit 3a9b71ab89
3 changed files with 83 additions and 29 deletions

View file

@ -10,7 +10,7 @@
## Shared 'core' config options ## Shared 'core' config options
../../../core ../../../core
## Host-specific core modules ## Host-specific core modules
../../../core/modules/optional/zfs.nix ../../../core/modules/optional/zfs2.nix
../../../core/modules/optional/gaming.nix ../../../core/modules/optional/gaming.nix
../../../core/modules/optional/jellyfin.nix ../../../core/modules/optional/jellyfin.nix

View file

@ -3,7 +3,7 @@
## temporary location while we figure out how ZFS works, ## temporary location while we figure out how ZFS works,
## eventually this will be embedded into the flake in a better way ## eventually this will be embedded into the flake in a better way
{ lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
## This 'let' binding creates an attribute set ## This 'let' binding creates an attribute set
@ -11,22 +11,16 @@ let
## a package to specify when building our kernel. ## a package to specify when building our kernel.
latestZfsLinux = lib.pipe pkgs.linuxKernel.packages [ latestZfsLinux = lib.pipe pkgs.linuxKernel.packages [
builtins.attrValues builtins.attrValues
(builtins.filter ( (builtins.filter (kPkgs:
kPkgs: (builtins.tryEval kPkgs).success && kPkgs ? kernel && kPkgs.kernel.pname
(builtins.tryEval kPkgs).success == "linux" && !kPkgs.zfs.meta.broken))
&& kPkgs ? kernel
&& kPkgs.kernel.pname == "linux"
&& !kPkgs.zfs.meta.broken
))
(builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version))) (builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version)))
lib.last lib.last
]; ];
in
{ in {
imports = [ imports = [ ];
];
## Enable zfs in kernel and boot ## Enable zfs in kernel and boot
boot = { boot = {
@ -44,9 +38,7 @@ in
#options = [ "users" ]; #options = [ "users" ];
#}; #};
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [ zfs ];
zfs
];
## Enable trim for ZFS SSDs ## Enable trim for ZFS SSDs
services = { services = {
@ -55,14 +47,10 @@ in
#trim.enable = true; #trim.enable = true;
## Autoscrub data integrity ZFS service, ## Autoscrub data integrity ZFS service,
## more to be added soon ## more to be added soon
autoScrub = { autoScrub = { enable = true; };
enable = true;
};
}; };
}; };
networking = { networking = { hostId = "603b0c8b"; };
hostId = "603b0c8b";
};
} }

66
core/modules/optional/zfs2.nix Executable file
View file

@ -0,0 +1,66 @@
# # 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, ... }:
## Black magic wizardry from https://wiki.nixos.org/wiki/ZFS
let
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 = [ ];
## Enable zfs in kernel and boot
boot = {
## Sets system to use the kernel specified in the let binding above
kernelPackages = lib.mkForce latestKernelPackage;
supportedFilesystems = [ "zfs" ];
zfs = {
## uhhh
extraPools = [ "orcus" ];
## uhhh
forceImportRoot = false;
};
};
#fileSystems."/run/media/serenity/Orcus" = {
#device = "orcus";
#fsType = "zfs";
#options = [ "users" ];
#};
## Adding ZFS package to system just in case
environment.systemPackages = with pkgs; [ zfs ];
## 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; };
};
};
## Automount service for the ZFS pools
## Is supposed to be enabled by default
#systemd.services.zfs-mount = {
#enable = true;
#};
## Unsure why this is here actually ?
networking = { hostId = "603b0c8b"; };
}