diff --git a/deployment/check/common/data-model.nix b/deployment/check/common/data-model.nix index ff29326c..3f069333 100644 --- a/deployment/check/common/data-model.nix +++ b/deployment/check/common/data-model.nix @@ -32,6 +32,10 @@ let vlanId imageDatastoreId vmDatastoreId + ipv4Gateway + ipv4Address + ipv6Gateway + ipv6Address ; inherit (lib) mkOption types; eval = @@ -348,6 +352,10 @@ let vlanId imageDatastoreId vmDatastoreId + ipv4Gateway + ipv4Address + ipv6Gateway + ipv6Address ; root-path = pathToRoot; }; diff --git a/deployment/check/data-model-tf-proxmox/nixosTest.nix b/deployment/check/data-model-tf-proxmox/nixosTest.nix index 484c7b1d..920b30f1 100644 --- a/deployment/check/data-model-tf-proxmox/nixosTest.nix +++ b/deployment/check/data-model-tf-proxmox/nixosTest.nix @@ -27,6 +27,10 @@ let vlanId = 0; imageDatastoreId = "local"; vmDatastoreId = "local"; + ipv4Gateway = "192.168.1.1"; + ipv4Address = "192.168.1.236/24"; + ipv6Gateway = ""; + ipv6Address = ""; }; # FIXME generate the image `nixos-generate` was to make, but now do it for a desired `-c configuration.nix` rather than whatever generic thing now deployment = diff --git a/deployment/check/data-model-tf/options.nix b/deployment/check/data-model-tf/options.nix index c0d4cf59..e259a4c6 100644 --- a/deployment/check/data-model-tf/options.nix +++ b/deployment/check/data-model-tf/options.nix @@ -54,5 +54,25 @@ in type = types.str; default = "local"; }; + ipv4Gateway = mkOption { + description = "Gateway for IPv4."; + type = types.str; + default = ""; + }; + ipv4Address = mkOption { + description = "IPv4 address."; + type = types.str; + default = ""; + }; + ipv6Gateway = mkOption { + description = "Gateway for IPv6."; + type = types.str; + default = ""; + }; + ipv6Address = mkOption { + description = "IPv6 address."; + type = types.str; + default = ""; + }; }; } diff --git a/deployment/data-model.nix b/deployment/data-model.nix index 41b0a4b8..abc1e82f 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -349,6 +349,26 @@ let type = types.str; default = "local"; }; + ipv4Gateway = mkOption { + description = "Gateway for IPv4."; + type = types.str; + default = ""; + }; + ipv4Address = mkOption { + description = "IPv4 address."; + type = types.str; + default = ""; + }; + ipv6Gateway = mkOption { + description = "Gateway for IPv6."; + type = types.str; + default = ""; + }; + ipv6Address = mkOption { + description = "IPv6 address."; + type = types.str; + default = ""; + }; run = mkOption { type = types.package; # error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times. @@ -370,6 +390,10 @@ let vlanId imageDatastoreId vmDatastoreId + ipv4Gateway + ipv4Address + ipv6Gateway + ipv6Address ; inherit (ssh) host @@ -440,6 +464,10 @@ let vlan_id = vlanId; image_datastore_id = imageDatastoreId; vm_datastore_id = vmDatastoreId; + ipv4_gateway = ipv4Gateway; + ipv4_address = ipv4Address; + ipv6_gateway = ipv6Gateway; + ipv6_address = ipv6Address; }; tf-env = pkgs.callPackage ./run/tf-env.nix { inherit httpBackend; diff --git a/deployment/run/tf-proxmox/main.tf b/deployment/run/tf-proxmox/main.tf index 479ad54b..00f27b1b 100644 --- a/deployment/run/tf-proxmox/main.tf +++ b/deployment/run/tf-proxmox/main.tf @@ -163,19 +163,18 @@ resource "proxmox_virtual_environment_vm" "nix_vm" { scsi_hardware = "virtio-scsi-single" bios = "ovmf" - # # used only for cloud-init - # initialization { - # ip_config { - # ipv4 { - # gateway = "eth0" - # address = "95.215.187.${proxmox_virtual_environment_vm.nix_vm.vm_id}" # error: self-referential block - # } - # ipv6 { - # gateway = "eth0" - # address = "2a00:51c0:13:1305::${proxmox_virtual_environment_vm.nix_vm.vm_id}" - # } - # } - # } + initialization { + ip_config { + ipv4 { + gateway = var.ipv4_gateway + address = var.ipv4_address + } + # ipv6 { + # gateway = var.ipv6_gateway + # address = var.ipv6_address + # } + } + } } resource "null_resource" "wait_for_ssh" { diff --git a/deployment/run/tf-proxmox/variables.tf b/deployment/run/tf-proxmox/variables.tf index 99d03ce5..60d6c92e 100644 --- a/deployment/run/tf-proxmox/variables.tf +++ b/deployment/run/tf-proxmox/variables.tf @@ -76,6 +76,30 @@ variable "vm_datastore_id" { default = "local" } +variable "ipv4_gateway" { + description = "Gateway for IPv4." + type = string + default = "" +} + +variable "ipv4_address" { + description = "IPv4 address." + type = string + default = "" +} + +variable "ipv6_gateway" { + description = "Gateway for IPv6." + type = string + default = "" +} + +variable "ipv6_address" { + description = "IPv6 address." + type = string + default = "" +} + ######################################### variable "category" { diff --git a/flake.nix b/flake.nix index b90c0f18..aeb01846 100644 --- a/flake.nix +++ b/flake.nix @@ -99,6 +99,12 @@ vlanId = 1305; imageDatastoreId = "local"; vmDatastoreId = "linstor_storage"; + ipv4Gateway = "eth0"; + ipv4Address = ""; + # ipv4Address = "95.215.187.${vm-id}"; + ipv6Gateway = "eth0"; + ipv6Address = ""; + # ipv6Address = "2a00:51c0:13:1305::${vm-id}"; }; # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call })."tf-proxmox-deployment".tf-proxmox-host;