Add NixOS ZFS EC2 AMI builder

This commit is contained in:
Timothy J. Aveni
2026-06-20 11:28:38 -07:00
commit b2e4b7fcaa
9 changed files with 681 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
{ config, lib, modulesPath, pkgs, ... }:
let
nixPool = "nixos-zfs-nix";
in
{
imports = [
"${modulesPath}/virtualisation/amazon-image.nix"
];
networking.hostName = "nixos-zfs-ec2";
networking.hostId = "6e69787a";
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = [
pkgs.amazon-ssm-agent
pkgs.git
pkgs.zfs
];
services.amazon-ssm-agent.enable = true;
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.extraPools = [ nixPool ];
boot.zfs.forceImportRoot = false;
fileSystems."/nix" = {
device = "${nixPool}/nix";
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" ];
};
system.stateVersion = "25.05";
}