51 lines
1.2 KiB
Nix
51 lines
1.2 KiB
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
cfg = config.quixos.modules.zfsNixStore;
|
|
in
|
|
{
|
|
# TODO: split this module into a small standalone repo if another AMI family
|
|
# needs to consume it outside the nixos-zfs-ec2-ami boundary.
|
|
options.quixos.modules.zfsNixStore = {
|
|
enable = lib.mkEnableOption "ZFS-backed /nix store mount";
|
|
|
|
pool = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "nixos-zfs-nix";
|
|
description = "ZFS pool containing the /nix dataset.";
|
|
};
|
|
|
|
dataset = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "nix";
|
|
description = "Dataset within the pool mounted at /nix.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
boot.zfs.extraPools = [ cfg.pool ];
|
|
boot.zfs.forceImportRoot = false;
|
|
|
|
fileSystems."/nix" = {
|
|
device = "${cfg.pool}/${cfg.dataset}";
|
|
fsType = "zfs";
|
|
neededForBoot = true;
|
|
options = [
|
|
"nofail"
|
|
"x-systemd.device-timeout=30s"
|
|
];
|
|
};
|
|
|
|
systemd.sockets.nix-daemon = {
|
|
after = [ "nix.mount" ];
|
|
requires = [ "nix.mount" ];
|
|
};
|
|
|
|
systemd.services.nix-daemon = {
|
|
after = [ "nix.mount" ];
|
|
requires = [ "nix.mount" ];
|
|
};
|
|
};
|
|
}
|