From d56a48cf65585add4e7bcd29ee0609ff2ea73db8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:22:31 -0500 Subject: [PATCH] add zfs module with options --- hosts/swan/default.nix | 7 ++++--- modules/nixos/hardware/default.nix | 1 + modules/nixos/hardware/zfs.nix | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 modules/nixos/hardware/zfs.nix diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index ba632f0..c207deb 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -19,6 +19,7 @@ nixpkgs.lib.nixosSystem { disko.nixosModules.disko { server = true; + zfs.enable = true; gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; @@ -36,9 +37,9 @@ nixpkgs.lib.nixosSystem { neovim.enable = true; - boot.zfs.enabled = true; - boot.kernelPackages = - config.boot.zfs.package.latestCompatibleLinuxPackages; + # boot.zfs.enabled = true; + # boot.kernelPackages = + # config.boot.zfs.package.latestCompatibleLinuxPackages; # boot.zfs.extraPools = [ "mypool" ]; # services.zfs.autoScrub.enable = true; # services.zfs.autoScrub.interval = "daily"; diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 8dd57a5..6d3f9f0 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -10,6 +10,7 @@ ./server.nix ./sleep.nix ./wifi.nix + ./zfs.nix ]; options = { diff --git a/modules/nixos/hardware/zfs.nix b/modules/nixos/hardware/zfs.nix new file mode 100644 index 0000000..07b82ea --- /dev/null +++ b/modules/nixos/hardware/zfs.nix @@ -0,0 +1,14 @@ +{ config, pkgs, lib, ... }: { + + options = { zfs.enable = lib.mkEnableOption "ZFS file system."; }; + + config = + lib.mkIf (pkgs.stdenv.isLinux && config.server && config.zfs.enable) { + + # Only use compatible Linux kernel, since ZFS can be behind + boot.kernelPackages = + config.boot.zfs.package.latestCompatibleLinuxPackages; + + }; + +}