summaryrefslogtreecommitdiff
path: root/archetypes/profiles/zfs/default.nix
blob: 484123195ca3ce907bcf435d48a672993e1e5b2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ lib, pkgs, ... }: let
	mkZfs = lib.mkOverride 810;

	# https://wiki.nixos.org/wiki/ZFS
	nixosConfig = {
		boot._loader = {
			grub.zfsSupport = mkZfs true;
			mode = mkZfs "efi";
		};

		services.zfs = {
			trim.enable = mkZfs true;
			autoSnapshot.enable = mkZfs true;
			autoScrub.enable = mkZfs true;
		};

		# Make docker work with zfs
		virtualisation.docker.storageDriver = mkZfs "zfs";

		# Ensure root pools are safely imported (default after 26.11)
		# NOTE: If NixOS fails to boot because it cannot import the root pool,
		# you should boot with the zfs_force=1 option as a kernel parameter
		# (e.g. by manually editing the kernel params via your bootloader). You
		# should only need to do this after unclean shutdowns.
		boot.zfs.forceImportRoot = mkZfs false;
	};

	homeConfig = {};
in {
	imports = [ (lib._mkProfileArchetype "zfs" nixosConfig homeConfig) ];
}