Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hosts/build01/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
imports = [
inputs.self.nixosModules.cgroups
inputs.self.nixosModules.community-builder
inputs.self.nixosModules.disko-zfs
#inputs.self.nixosModules.community-builder
inputs.self.nixosModules.disko-zfs-systemd-boot
inputs.srvos.nixosModules.hardware-hetzner-online-amd
];

Expand Down
2 changes: 1 addition & 1 deletion modules/nixos/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
./security.nix
./sops-nix.nix
./telegraf.nix
./update.nix
#./update.nix
./users.nix
inputs.srvos.nixosModules.server
];
Expand Down
75 changes: 75 additions & 0 deletions modules/nixos/disko-zfs-systemd-boot.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
config,
inputs,
lib,
...
}:
let
devices = idx: {
type = "disk";
device = "/dev/nvme${idx}n1";
content = {
type = "gpt";
partitions = {
ESP = lib.mkIf (idx == "0") {
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "nofail" ];
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
in
{
imports = [ inputs.disko.nixosModules.disko ];

boot.loader.systemd-boot.enable = true;

# the default zpool import services somehow times out while this import works fine?
boot.initrd.systemd.services.zfs-import-zroot.serviceConfig.ExecStartPre =
"${config.boot.zfs.package}/bin/zpool import -N -f zroot";

# Sometimes fails after the first try, with duplicate pool name errors
boot.initrd.systemd.services.zfs-import-zroot.serviceConfig.Restart = "on-failure";

disko.devices = {
disk = {
x = devices "0";
y = devices "1";
};
zpool = {
zroot = {
type = "zpool";
options = {
ashift = "12";
};
rootFsOptions = {
acltype = "posixacl";
atime = "off";
compression = "lz4";
mountpoint = "none";
xattr = "sa";
"com.sun:auto-snapshot" = "false";
};
datasets = {
root = {
type = "zfs_fs";
mountpoint = "/";
};
};
};
};
};
}