diff --git a/hosts/blade/default.nix b/hosts/blade/default.nix index 2b122ec..e94c4d5 100644 --- a/hosts/blade/default.nix +++ b/hosts/blade/default.nix @@ -7,7 +7,9 @@ ... }: { - + imports = [ + ../../common/incus.nix + ]; deployment = { targetHost = "192.168.1.69"; targetPort = 22; diff --git a/modules/common.nix b/modules/common.nix index dca178a..fc6cdb8 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -7,5 +7,6 @@ ./common/services.nix ./common/networking.nix ./common/system.nix + ./common/persisting.nix ]; } diff --git a/modules/common/incus.nix b/modules/common/incus.nix new file mode 100644 index 0000000..c1b3584 --- /dev/null +++ b/modules/common/incus.nix @@ -0,0 +1,77 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + virtualisation = { + # GPU virtualisation (Intel GVT-g) + kvmgt.enable = true; + # Incus (Virtual Machine and System Container management) + incus = { + enable = true; + ui.enable = true; + package = pkgs.incus-lts; # use 'pkgs.incus' for feature releases + preseed = { + networks = [ + { + name = "internalbr0"; + type = "bridge"; + description = "Internal/NATted bridge"; + config = { + "ipv4.address" = "auto"; + "ipv4.nat" = "true"; + "ipv6.address" = "auto"; + "ipv6.nat" = "true"; + }; + } + ]; + profiles = [ + { + name = "default"; + description = "Default Incus Profile"; + devices = { + eth0 = { + name = "eth0"; + network = "internalbr0"; + type = "nic"; + }; + root = { + path = "/"; + pool = "default"; + type = "disk"; + }; + }; + } + { + name = "bridged"; + description = "Instances bridged to LAN"; + devices = { + eth0 = { + name = "eth0"; + nictype = "bridged"; + parent = "externalbr0"; + type = "nic"; + }; + root = { + path = "/"; + pool = "default"; + type = "disk"; + }; + }; + } + ]; + storage_pools = [ + { + config = { + source = "/var/lib/incus/storage-pools/default"; + }; + driver = "dir"; + name = "default"; + } + ]; + }; + }; + }; +} diff --git a/modules/common/persisting.nix b/modules/common/persisting.nix new file mode 100644 index 0000000..4e88325 --- /dev/null +++ b/modules/common/persisting.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +{ + persisting = { + enable = true; + + # Default directories to persist + directories = [ + { + path = "/persist"; + target = "/persist"; + options = [ "defaults" "bind" ]; + } + { + path = "/var/log"; + target = "/var/log"; + options = [ "defaults" "bind" ]; + } + { + path = "/var/lib"; + target = "/var/lib"; + options = [ "defaults" "bind" ]; + } + ]; + }; + + # Ensure persist directory exists + systemd.tmpfiles.rules = [ + "d /persist 0755 root root - -" + ]; +}