From 0758f6aa5ba4a5e7524ded5e7b708c577ccea2d8 Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra Date: Sat, 11 Oct 2025 14:37:39 +0200 Subject: [PATCH] rm bash-proxmox Signed-off-by: Kiara Grouwstra --- deployment/check/common/data-model.nix | 44 ------- .../data-model-bash-proxmox/constants.nix | 10 -- .../check/data-model-bash-proxmox/default.nix | 46 ------- .../data-model-bash-proxmox/nixosTest.nix | 103 --------------- deployment/check/data-model-tf/options.nix | 38 ++++++ deployment/data-model.nix | 120 ------------------ deployment/flake-part.nix | 4 - flake.nix | 73 ++++------- 8 files changed, 64 insertions(+), 374 deletions(-) delete mode 100644 deployment/check/data-model-bash-proxmox/constants.nix delete mode 100644 deployment/check/data-model-bash-proxmox/default.nix delete mode 100644 deployment/check/data-model-bash-proxmox/nixosTest.nix create mode 100644 deployment/check/data-model-tf/options.nix diff --git a/deployment/check/common/data-model.nix b/deployment/check/common/data-model.nix index 5cd26516..08442b0a 100644 --- a/deployment/check/common/data-model.nix +++ b/deployment/check/common/data-model.nix @@ -28,7 +28,6 @@ let proxmox-user proxmox-password node-name - vm-names ; inherit (lib) mkOption types; eval = @@ -313,38 +312,6 @@ let }; }; }; - single-nixos-vm-bash-proxmox = environment: { - resources."operator-environment".login-shell.username = "operator"; - implementation = - { - required-resources, - deployment-name, - }: - { - bash-proxmox-host = { - nixos-configuration = mkNixosConfiguration environment required-resources; - system = targetSystem; - # ssh = { - # username = "root"; - # host = nodeName; - # key-file = null; - # inherit sshOpts; - # }; - module = self; - inherit - args - deployment-name - # proxmox-host - proxmox-user - proxmox-password - node-name - vm-names - ; - proxmox-host = nodeName; - root-path = pathToRoot; - }; - }; - }; single-nixos-vm-tf-proxmox = environment: { resources."operator-environment".login-shell = { wheel = true; @@ -421,17 +388,6 @@ let configuration = config."example-configuration"; }; }; - "bash-proxmox-deployment" = - let - env = config.environments."single-nixos-vm-bash-proxmox"; - in - mkOption { - type = env.resource-mapping.output-type; - default = env.deployment { - deployment-name = "bash-proxmox-deployment"; - configuration = config."example-configuration"; - }; - }; "tf-proxmox-deployment" = let env = config.environments."single-nixos-vm-tf-proxmox"; diff --git a/deployment/check/data-model-bash-proxmox/constants.nix b/deployment/check/data-model-bash-proxmox/constants.nix deleted file mode 100644 index ab703ea7..00000000 --- a/deployment/check/data-model-bash-proxmox/constants.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - targetMachines = [ - "pve" - ]; - pathToRoot = builtins.path { - path = ../../..; - name = "root"; - }; - pathFromRoot = "/deployment/check/data-model-bash-proxmox"; -} diff --git a/deployment/check/data-model-bash-proxmox/default.nix b/deployment/check/data-model-bash-proxmox/default.nix deleted file mode 100644 index c6c8131b..00000000 --- a/deployment/check/data-model-bash-proxmox/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ - inputs, - sources, - system, -}: - -let - pkgs = import sources.nixpkgs-stable { - inherit system; - overlays = [ overlay ]; - }; - overlay = _: _: { - inherit - (import "${sources.proxmox-nixos}/pkgs" { - craneLib = pkgs.callPackage "${sources.crane}/lib" { }; - # breaks from https://github.com/NixOS/nixpkgs/commit/06b354eb2dc535c57e9b4caaa16d79168f117a26, - # which updates libvncserver to 0.9.15, which was not yet patched at https://git.proxmox.com/?p=vncterm.git. - inherit pkgs; - # not so picky about version for our purposes - pkgs-unstable = pkgs; - }) - proxmox-ve - pve-ha-manager - ; - }; -in -pkgs.testers.runNixOSTest { - node.specialArgs = { - inherit - sources - pkgs - ; - }; - imports = [ - ../../data-model.nix - ../../function.nix - ../common/nixosTest.nix - ./nixosTest.nix - ]; - _module.args = { inherit inputs sources; }; - inherit (import ./constants.nix) - targetMachines - pathToRoot - pathFromRoot - ; -} diff --git a/deployment/check/data-model-bash-proxmox/nixosTest.nix b/deployment/check/data-model-bash-proxmox/nixosTest.nix deleted file mode 100644 index 47aa8218..00000000 --- a/deployment/check/data-model-bash-proxmox/nixosTest.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ - lib, - pkgs, - sources, - ... -}: -let - inherit (pkgs) system; - deployment-config = { - inherit (import ./constants.nix) pathToRoot; - nodeName = "pve"; - targetSystem = system; - sshOpts = [ ]; - proxmox-user = "root@pam"; - proxmox-password = "mytestpw"; - node-name = "pve"; - vm-names = [ "test14" ]; - }; - # 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 = - (import ../common/data-model.nix { - inherit system; - config = deployment-config; - # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call - })."bash-proxmox-deployment".bash-proxmox-host; -in -{ - _class = "nixosTest"; - imports = [ - ../common/data-model-options.nix - ]; - - name = "deployment-model"; - sourceFileset = lib.fileset.unions [ - ../../run/tf-proxmox/run.sh - ]; - - nodes.pve = - { sources, ... }: - { - imports = [ - "${sources.proxmox-nixos}/modules/proxmox-ve" - ]; - users.users.root = { - password = "mytestpw"; - hashedPasswordFile = lib.mkForce null; - }; - services.proxmox-ve = { - enable = true; - ipAddress = "192.168.1.1"; - }; - virtualisation = { - diskSize = 2 * 1024; - memorySize = 2048; - }; - }; - - nodes.deployer = - { ... }: - { - nix.nixPath = [ - (lib.concatStringsSep ":" (lib.mapAttrsToList (k: v: k + "=" + v) sources)) - ]; - - environment.systemPackages = [ - deployment.run - ]; - - # needed only when building from deployer - system.extraDependenciesFromModule = - { pkgs, ... }: - { - environment.systemPackages = with pkgs; [ - hello - ]; - }; - system.extraDependencies = [ - pkgs.gnu-config - pkgs.byacc - pkgs.stdenv - pkgs.stdenvNoCC - sources.nixpkgs - pkgs.vte - ]; - }; - - extraTestScript = '' - pve.wait_for_unit("pveproxy.service") - assert "running" in pve.succeed("pveproxy status") - pve.succeed("mkdir -p /run/pve") - assert "Proxmox" in pve.succeed("curl -s -i -k https://localhost:8006") - # pve.succeed("pvesh get /nodes && exit 1") - - # pve.succeed("pvesh set /access/password --userid root@pam --password mypwdlol --confirmation-password mytestpw 1>&2") - # pve.succeed("curl -s -i -k -d '{\"userid\":\"root@pam\",\"password\":\"mypwdhaha\",\"confirmation-password\":\"mypwdlol\"}' -X PUT https://localhost:8006/api2/json/access/password 1>&2") - - with subtest("Run the deployment"): - deployer.succeed(""" - ${lib.getExe deployment.run} - """) - # target.succeed("su - operator -c hello 1>&2") - ''; -} diff --git a/deployment/check/data-model-tf/options.nix b/deployment/check/data-model-tf/options.nix new file mode 100644 index 00000000..035cb047 --- /dev/null +++ b/deployment/check/data-model-tf/options.nix @@ -0,0 +1,38 @@ +{ + lib, + ... +}: +let + inherit (lib) mkOption types; +in +{ + options = { + targetSystem = mkOption { + type = types.str; + description = "name of the host to deploy to"; + }; + sshOpts = mkOption { + description = "Extra SSH options (`-o`) to use."; + type = types.listOf types.str; + default = [ ]; + example = "ConnectTimeout=60"; + }; + httpBackend = mkOption { + description = "environment variables to configure the TF HTTP back-end, see "; + type = types.attrsOf (types.either types.str types.int); + }; + proxmox-user = mkOption { + description = "The ProxmoX user to use."; + type = types.str; + default = "root@pam"; + }; + proxmox-password = mkOption { + description = "The ProxmoX password to use."; + type = types.str; + }; + node-name = mkOption { + description = "the name of the ProxmoX node to use."; + type = types.str; + }; + }; +} diff --git a/deployment/data-model.nix b/deployment/data-model.nix index db75e9c6..745f3530 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -284,115 +284,6 @@ let }; }); }; - bash-proxmox-host = mkOption { - description = "A bash deployment by SSH to create or update a NixOS VM in ProxmoX."; - type = submodule (bash-proxmox-host: { - options = { - system = mkOption { - description = "The architecture of the system to deploy to."; - type = types.str; - }; - inherit nixos-configuration; - # TODO: add proxmox info - module = mkOption { - description = "The module to call to obtain the NixOS configuration from."; - type = types.str; - }; - args = mkOption { - description = "The arguments with which to call the module to obtain the NixOS configuration."; - type = types.attrs; - }; - deployment-name = mkOption { - description = "The name of the deployment for which to obtain the NixOS configuration."; - type = types.str; - }; - root-path = mkOption { - description = "The path to the root of the repository."; - type = types.path; - }; - proxmox-host = mkOption { - description = "The host of the ProxmoX instance to use."; - type = types.str; - default = "192.168.51.81"; - }; - vm-names = mkOption { - description = "The names of VMs to provision."; - type = types.listOf types.str; - }; - proxmox-user = mkOption { - description = "The ProxmoX user to use."; - type = types.str; - default = "root@pam"; - }; - # TODO: is sensitivity here handled properly? - proxmox-password = mkOption { - description = "The ProxmoX password to use."; - type = types.str; - }; - node-name = mkOption { - description = "the name of the ProxmoX node to use."; - type = types.str; - }; - run = mkOption { - type = types.package; - # error: The option `.run' is read-only, but it's set multiple times. - # readOnly = true; - default = - let - deployment-type = "bash-proxmox-host"; - inherit (bash-proxmox-host.config) - system - module - args - deployment-name - root-path - node-name - proxmox-host - proxmox-user - proxmox-password - vm-names - ; - nixos_conf = writeConfig { - inherit - system - module - args - deployment-name - root-path - deployment-type - ; - }; - in - pkgs.writers.writeBashBin "provision-proxmox.sh" - (withPackages [ - pkgs.httpie - pkgs.jq - ]) - '' - bash ./infra/proxmox-remove.sh \ - --api-url "https://${proxmox-host}:8006/api2/json" \ - --username "${proxmox-user}" \ - --password "${proxmox-password}" \ - --node "${node-name}" \ - 7014 - # ^ hardcoded ID of test14 - # ${lib.concatStringsSep " " vm-names} - - bash ./infra/proxmox-provision.sh \ - --api-url "https://${proxmox-host}:8006/api2/json" \ - --username "${proxmox-user}" \ - --password "${proxmox-password}" \ - --node "${node-name}" \ - ${ - # lib.concatStringsSep " " vm-names - lib.concatStringsSep " " (lib.lists.map (k: "${k}:${nixos_conf}") vm-names) - } - # ${lib.concatStringsSep " " vm-names} - ''; - }; - }; - }); - }; tf-proxmox-host = mkOption { description = "A Terraform deployment by SSH to update a single existing NixOS host."; # type = submodule (tf-host: { @@ -555,8 +446,6 @@ let "deployment/run/tf-proxmox" ]; }; - proxmox-host = "192.168.51.81"; # root@fediversity-proxmox - vm-names = [ "test14" ]; vm_name = "test14"; in lib.trace (lib.strings.toJSON environment) pkgs.writers.writeBashBin "deploy-tf-proxmox.sh" @@ -570,15 +459,6 @@ let '' set -e - # bash ./infra/proxmox-remove.sh \ - # --api-url "https://${proxmox-host}:8006/api2/json" \ - # --username "${proxmox-user}" \ - # --password "${proxmox-password}" \ - # --node "${node-name}" \ - # 7014 - # # ^ hardcoded ID of test14 - # # ${lib.concatStringsSep " " vm-names} - # TODO after install: $nix_host_keys # cp $tmpdir/${vm_name}_host_key /mnt/etc/ssh/ssh_host_ed25519_key # chmod 600 /mnt/etc/ssh/ssh_host_ed25519_key diff --git a/deployment/flake-part.nix b/deployment/flake-part.nix index 5d2b12cb..6ca47b4c 100644 --- a/deployment/flake-part.nix +++ b/deployment/flake-part.nix @@ -41,10 +41,6 @@ inherit inputs sources system; }; - deployment-model-bash-proxmox = import ./check/data-model-bash-proxmox { - inherit inputs sources system; - }; - deployment-model-tf-proxmox = import ./check/data-model-tf-proxmox { inherit inputs sources system; }; diff --git a/flake.nix b/flake.nix index e3d47627..fa567ae5 100644 --- a/flake.nix +++ b/flake.nix @@ -78,54 +78,33 @@ # api_token = "terraform@pve!provider=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # kiara@ProcoliX!dsdfsfdsfd=30df234b-02f3-4ed9-b778-00d28ad3499c - # # iso: No bootable option or device was found - # apps.default = let - # inherit (pkgs) system; - # deployment = - # (import ./deployment/check/common/data-model.nix { - # inherit system; - # config = { - # targetSystem = system; - # nodeName = "192.168.51.81"; # root@fediversity-proxmox - # pathToRoot = builtins.path { - # path = ./.; - # name = "root"; - # }; - # sshOpts = []; - # proxmox-user = "kiara@ProcoliX"; - # proxmox-password = ""; - # node-name = "node051"; - # vm-names = [ "test14" ]; - # }; - # })."bash-proxmox-deployment".bash-proxmox-host; - # in { - # type = "app"; - # program = deployment.run; - # }; - - apps.default = let - inherit (pkgs) system; - deployment = - (import ./deployment/check/common/data-model.nix { - inherit system; - config = { - targetSystem = system; - nodeName = "192.168.51.81"; # root@fediversity-proxmox - pathToRoot = builtins.path { - path = ./.; - name = "root"; + apps.default = + let + inherit (pkgs) system; + deployment = + (import ./deployment/check/common/data-model.nix { + inherit system; + config = { + targetSystem = system; + nodeName = "192.168.51.81"; # root@fediversity-proxmox + pathToRoot = builtins.path { + path = ./.; + name = "root"; + }; + sshOpts = [ ]; + proxmox-user = "kiara@ProcoliX"; + proxmox-password = ""; + node-name = "node051"; + bridge = "ovsbr0"; + vlanId = 1305; }; - sshOpts = []; - proxmox-user = "kiara@ProcoliX"; - proxmox-password = ""; - node-name = "node051"; - }; - # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call - })."tf-proxmox-deployment".tf-proxmox-host; - in { - type = "app"; - program = deployment.run; - }; + # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call + })."tf-proxmox-deployment".tf-proxmox-host; + in + { + type = "app"; + program = deployment.run; + }; }; }