From bb100b698edbf3fce39f749781877d61bafc8930 Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra Date: Fri, 21 Nov 2025 13:03:27 +0100 Subject: [PATCH] Revert "inline proxmox-template call (#588)" (#592) Reverts commit 65a14f63ff01acf51cd22826d75e60e287b79efb, which seems to have caused a regression. Reviewed-on: https://git.fediversity.eu/fediversity/fediversity/pulls/592 --- .../check/data-model-tf-proxmox/nixosTest.nix | 60 +++------------- .../{ => setups}/shared.nix | 4 +- .../data-model-tf-proxmox/setups/template.nix | 70 +++++++++++++++++++ .../{data-model.nix => setups/vm.nix} | 8 +-- 4 files changed, 87 insertions(+), 55 deletions(-) rename deployment/check/data-model-tf-proxmox/{ => setups}/shared.nix (94%) create mode 100644 deployment/check/data-model-tf-proxmox/setups/template.nix rename deployment/check/data-model-tf-proxmox/{data-model.nix => setups/vm.nix} (89%) diff --git a/deployment/check/data-model-tf-proxmox/nixosTest.nix b/deployment/check/data-model-tf-proxmox/nixosTest.nix index 09389b3d..79a4cece 100644 --- a/deployment/check/data-model-tf-proxmox/nixosTest.nix +++ b/deployment/check/data-model-tf-proxmox/nixosTest.nix @@ -7,61 +7,23 @@ }: let inherit (pkgs) system; - inherit (pkgs.callPackage ../../utils.nix { }) evalModel; - inherit (pkgs.callPackage ../common/utils.nix { inherit modulesPath; }) mkNixosConfiguration; backendPort = builtins.toString 8080; tfBackend = fragment: { address = "http://localhost:${backendPort}/state/${fragment}"; }; template-deployment = - (evalModel ( - { config, ... }: - { - imports = [ ../common/model.nix ]; - config = { - environments.default = environment: { - resources."operator-environment".login-shell = { - wheel = true; - username = "operator"; - }; - implementation = - { - required-resources, - ... - }: - { - tf-proxmox-template = { - nixos-configuration = { - imports = [ - (mkNixosConfiguration environment required-resources) - ./shared.nix - ]; - }; - inherit system; - ssh.host = "pve"; - httpBackend = tfBackend "proxmox-test/upload"; - node-name = "pve"; - imageDatastoreId = "local"; - }; - }; - }; - }; - options.default = - let - env = config.environments.default; - in - lib.mkOption { - type = env.resource-mapping.output-type; - default = env.deployment { - deployment-name = "default"; - # normally our template is distinct, but our test cannot download build deps due to sandboxing - configuration = config."example-configuration"; - }; - }; - } - )).default.tf-proxmox-template; + (import ./setups/template.nix { + inherit sources system modulesPath; + config = { + httpBackend = tfBackend "proxmox-test/upload"; + nodeName = "pve"; + targetSystem = system; + node-name = "pve"; + imageDatastoreId = "local"; + }; + }).default.tf-proxmox-template; vm-deployment = - (import ./data-model.nix { + (import ./setups/vm.nix { inherit sources system modulesPath; config = { httpBackend = tfBackend "proxmox-test/nixos"; diff --git a/deployment/check/data-model-tf-proxmox/shared.nix b/deployment/check/data-model-tf-proxmox/setups/shared.nix similarity index 94% rename from deployment/check/data-model-tf-proxmox/shared.nix rename to deployment/check/data-model-tf-proxmox/setups/shared.nix index 69f803a0..3ea6b94e 100644 --- a/deployment/check/data-model-tf-proxmox/shared.nix +++ b/deployment/check/data-model-tf-proxmox/setups/shared.nix @@ -1,12 +1,12 @@ { lib, - sources ? import ../../../npins, + sources ? import ../../../../npins, ... }: { imports = [ "${sources.disko}/module.nix" - ../../../infra/common/proxmox-qemu-vm.nix + ../../../../infra/common/proxmox-qemu-vm.nix ]; networking.useDHCP = false; services.qemuGuest.enable = true; diff --git a/deployment/check/data-model-tf-proxmox/setups/template.nix b/deployment/check/data-model-tf-proxmox/setups/template.nix new file mode 100644 index 00000000..983ef8c9 --- /dev/null +++ b/deployment/check/data-model-tf-proxmox/setups/template.nix @@ -0,0 +1,70 @@ +{ + config, + system, + modulesPath, + sources ? import ../../../../npins, + ... +}: +let + inherit (sources) nixpkgs; + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) lib; + inherit (pkgs.callPackage ../../common/utils.nix { inherit modulesPath; }) mkNixosConfiguration; + inherit (config) + nodeName + targetSystem + httpBackend + node-name + imageDatastoreId + ; +in +(pkgs.callPackage ../../../utils.nix { }).evalModel ( + { config, ... }: + { + imports = [ ../../common/model.nix ]; + config = { + environments.default = environment: { + resources."operator-environment".login-shell = { + wheel = true; + username = "operator"; + }; + implementation = + { + required-resources, + ... + }: + { + tf-proxmox-template = { + nixos-configuration = { + imports = [ + (mkNixosConfiguration environment required-resources) + ./shared.nix + ]; + }; + system = targetSystem; + ssh = { + host = nodeName; + }; + inherit + node-name + httpBackend + imageDatastoreId + ; + }; + }; + }; + }; + options.default = + let + env = config.environments.default; + in + lib.mkOption { + type = env.resource-mapping.output-type; + default = env.deployment { + deployment-name = "default"; + # normally our template is distinct, but our test cannot download build deps due to sandboxing + configuration = config."example-configuration"; + }; + }; + } +) diff --git a/deployment/check/data-model-tf-proxmox/data-model.nix b/deployment/check/data-model-tf-proxmox/setups/vm.nix similarity index 89% rename from deployment/check/data-model-tf-proxmox/data-model.nix rename to deployment/check/data-model-tf-proxmox/setups/vm.nix index 86e23159..167eb8e3 100644 --- a/deployment/check/data-model-tf-proxmox/data-model.nix +++ b/deployment/check/data-model-tf-proxmox/setups/vm.nix @@ -2,14 +2,14 @@ config, system, modulesPath, - sources ? import ../../../npins, + sources ? import ../../../../npins, ... }@args: let inherit (sources) nixpkgs; pkgs = import nixpkgs { inherit system; }; inherit (pkgs) lib; - inherit (pkgs.callPackage ../common/utils.nix { inherit modulesPath; }) mkNixosConfiguration; + inherit (pkgs.callPackage ../../common/utils.nix { inherit modulesPath; }) mkNixosConfiguration; inherit (config) nodeName pathToRoot @@ -30,10 +30,10 @@ let ipv6Address ; in -(pkgs.callPackage ../../utils.nix { }).evalModel ( +(pkgs.callPackage ../../../utils.nix { }).evalModel ( { config, ... }: { - imports = [ ../common/model.nix ]; + imports = [ ../../common/model.nix ]; config = { environments.default = environment: { resources."operator-environment".login-shell = {