un-hardcode networking info

Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
Kiara Grouwstra 2025-10-13 11:38:21 +02:00
parent c0682276fc
commit 72a54bc093
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
6 changed files with 45 additions and 3 deletions

View file

@ -28,6 +28,8 @@ let
proxmox-user proxmox-user
proxmox-password proxmox-password
node-name node-name
bridge
vlanId
; ;
inherit (lib) mkOption types; inherit (lib) mkOption types;
eval = eval =
@ -340,6 +342,8 @@ let
proxmox-user proxmox-user
proxmox-password proxmox-password
node-name node-name
bridge
vlanId
; ;
root-path = pathToRoot; root-path = pathToRoot;
}; };

View file

@ -23,6 +23,8 @@ let
proxmox-user = "root@pam"; proxmox-user = "root@pam";
proxmox-password = "mytestpw"; proxmox-password = "mytestpw";
node-name = "pve"; node-name = "pve";
bridge = "br0";
vlanId = 0;
}; };
# 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 # 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 = deployment =

View file

@ -34,5 +34,15 @@ in
description = "the name of the ProxmoX node to use."; description = "the name of the ProxmoX node to use.";
type = types.str; type = types.str;
}; };
bridge = mkOption {
description = "The name of the network bridge (defaults to vmbr0).";
type = types.str;
default = "vmbr0";
};
vlanId = mkOption {
description = "The VLAN identifier.";
type = types.int;
default = 0;
};
}; };
} }

View file

@ -354,6 +354,16 @@ let
description = "environment variables to configure the TF HTTP back-end, see <https://developer.hashicorp.com/terraform/language/backend/http#configuration-variables>"; description = "environment variables to configure the TF HTTP back-end, see <https://developer.hashicorp.com/terraform/language/backend/http#configuration-variables>";
type = types.attrsOf (types.either types.str types.int); type = types.attrsOf (types.either types.str types.int);
}; };
bridge = mkOption {
description = "The name of the network bridge (defaults to vmbr0).";
type = types.str;
default = "vmbr0";
};
vlanId = mkOption {
description = "The VLAN identifier.";
type = types.int;
default = 0;
};
run = mkOption { run = mkOption {
type = types.package; type = types.package;
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times. # error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
@ -371,6 +381,8 @@ let
proxmox-user proxmox-user
proxmox-password proxmox-password
node-name node-name
bridge
vlanId
; ;
inherit (ssh) inherit (ssh)
host host
@ -432,11 +444,13 @@ let
inherit inherit
host host
nixos_conf nixos_conf
bridge
; ;
node_name = node-name;
proxmox_user = proxmox-user; proxmox_user = proxmox-user;
proxmox_password = proxmox-password; proxmox_password = proxmox-password;
ssh_user = username; ssh_user = username;
node_name = node-name; vlan_id = vlanId;
}; };
tf-env = pkgs.callPackage ./run/tf-env.nix { tf-env = pkgs.callPackage ./run/tf-env.nix {
inherit httpBackend; inherit httpBackend;

View file

@ -161,8 +161,8 @@ resource "proxmox_virtual_environment_vm" "nix_vm" {
network_device { network_device {
model = "virtio" model = "virtio"
bridge = "ovsbr0" bridge = var.bridge
vlan_id = 1305 vlan_id = var.vlan_id
} }
operating_system { operating_system {

View file

@ -51,6 +51,18 @@ variable "image" {
type = string type = string
} }
variable "bridge" {
description = "The name of the network bridge (defaults to vmbr0)."
type = string
default = "vmbr0"
}
variable "vlan_id" {
description = "The VLAN identifier."
type = number
default = 0
}
######################################### #########################################
variable "category" { variable "category" {