Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
Kiara Grouwstra 2025-09-23 13:42:49 +02:00
parent 6426e70b84
commit bd631227e7
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU

View file

@ -388,32 +388,7 @@ let
tf-proxmox-host = mkOption { tf-proxmox-host = mkOption {
description = "A Terraform deployment by SSH to update a single existing NixOS host."; description = "A Terraform deployment by SSH to update a single existing NixOS host.";
# type = submodule (tf-host: { # type = submodule (tf-host: {
type = submodule ( type = submodule (tf-host: {
tf-host:
let
raw = {
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/raw.nix";
formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/raw-efi.nix";
formatAttr = "raw";
fileExtension = ".img";
};
format = raw;
# qcow = {
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/qcow.nix";
# formatAttr = "qcow";
# fileExtension = ".qcow2";
# };
# format = qcow;
# qcow-efi = {
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/qcow-efi.nix";
# formatAttr = "qcow-efi";
# fileExtension = ".qcow2";
# };
# format = qcow-efi;
inherit (format) formatConfig fileExtension formatAttr;
# inherit (format) formatConfig fileExtension; # formatAttr
in
{
options = { options = {
system = mkOption { system = mkOption {
description = "The architecture of the system to deploy to."; description = "The architecture of the system to deploy to.";
@ -469,29 +444,6 @@ let
proxmox-password proxmox-password
node-name node-name
; ;
# image = let
# # TODO parameterize things to let this flow into the terraform
# # btw qcow can be made by nixos-generators (qcow, qcow-efi) or by `image.repart`
# # wait, so i generate an image for the nixos config from the data model? how would i then propagate that to deploy?
# gen = import "${pkgs.nixos-generators}/share/nixos-generator/nixos-generate.nix" {
# inherit system formatConfig;
# inherit (sources) nixpkgs;
# # configuration = import "${pkgs.nixos-generators}/share/nixos-generator/configuration.nix";
# # formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/proxmox.nix";
# configuration = tf-host.config.nixos-configuration;
# # configuration = {
# # imports = [
# # # "${pkgs.nixos-generators}/share/nixos-generator/configuration.nix"
# # # "${sources.nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
# # # "${sources.agenix}/modules/age.nix"
# # # "${sources.disko}/module.nix"
# # # "${sources.home-manager}/nixos"
# # ];
# # };
# };
# machine = gen.config;
# in
# machine.system.build.${formatAttr};
inherit (ssh) inherit (ssh)
host host
username username
@ -509,6 +461,12 @@ let
deployment-type deployment-type
; ;
}; };
# machine = import nixos_conf;
machine = import ./nixos.nix {
inherit sources system;
configuration = tf-host.config.nixos-configuration;
};
environment = { environment = {
key_file = key-file; key_file = key-file;
ssh_opts = sshOpts; ssh_opts = sshOpts;
@ -520,11 +478,8 @@ let
proxmox_password = proxmox-password; proxmox_password = proxmox-password;
ssh_user = username; ssh_user = username;
node_name = node-name; node_name = node-name;
# image = "${image}/nixos${fileExtension}"; image = "${machine.config.system.build.image}/${machine.config.boot.uki.name}.raw";
# image = "${image}/nixos.img";
}; };
# image = "${image}/nixos${fileExtension}";
# image = "${image}/nixos.img";
tf-env = pkgs.callPackage ./run/tf-proxmox/tf-env.nix { }; tf-env = pkgs.callPackage ./run/tf-proxmox/tf-env.nix { };
proxmox-host = "192.168.51.81"; # root@fediversity-proxmox proxmox-host = "192.168.51.81"; # root@fediversity-proxmox
vm-names = [ "test14" ]; vm-names = [ "test14" ];
@ -538,6 +493,8 @@ let
pkgs.httpie pkgs.httpie
(pkgs.callPackage ./run/tf-proxmox/tf.nix { inherit sources; }) (pkgs.callPackage ./run/tf-proxmox/tf.nix { inherit sources; })
]) ])
lib.trace
(lib.strings.toJSON environment)
'' ''
set -xe set -xe
@ -556,29 +513,12 @@ let
# cp $tmpdir/${vm_name}_host_key.pub /mnt/etc/ssh/ssh_host_ed25519_key.pub # cp $tmpdir/${vm_name}_host_key.pub /mnt/etc/ssh/ssh_host_ed25519_key.pub
# chmod 644 /mnt/etc/ssh/ssh_host_ed25519_key.pub # chmod 644 /mnt/etc/ssh/ssh_host_ed25519_key.pub
qemu-img convert -f raw -O qcow2 -C ${(import nixos_conf).config.system.build.image}/monkey.raw /tmp/disk.qcow2 env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
exit 1
# TF_VAR_image=/tmp/disk.qcow2 \
env ${
toString (
lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") (
lib.trace (lib.strings.toJSON environment) environment
)
)
} \
TF_VAR_image=/tmp/disk.qcow2 \
tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh
# env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
# tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh
''; '';
}; };
}; };
} });
);
}; };
}; };
in in