forked from fediversity/fediversity
simplify
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
parent
6426e70b84
commit
bd631227e7
1 changed files with 118 additions and 178 deletions
|
@ -388,32 +388,7 @@ let
|
|||
tf-proxmox-host = mkOption {
|
||||
description = "A Terraform deployment by SSH to update a single existing NixOS host.";
|
||||
# type = submodule (tf-host: {
|
||||
type = submodule (
|
||||
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
|
||||
{
|
||||
type = submodule (tf-host: {
|
||||
options = {
|
||||
system = mkOption {
|
||||
description = "The architecture of the system to deploy to.";
|
||||
|
@ -469,29 +444,6 @@ let
|
|||
proxmox-password
|
||||
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)
|
||||
host
|
||||
username
|
||||
|
@ -509,6 +461,12 @@ let
|
|||
deployment-type
|
||||
;
|
||||
};
|
||||
# machine = import nixos_conf;
|
||||
machine = import ./nixos.nix {
|
||||
inherit sources system;
|
||||
configuration = tf-host.config.nixos-configuration;
|
||||
};
|
||||
|
||||
environment = {
|
||||
key_file = key-file;
|
||||
ssh_opts = sshOpts;
|
||||
|
@ -520,11 +478,8 @@ let
|
|||
proxmox_password = proxmox-password;
|
||||
ssh_user = username;
|
||||
node_name = node-name;
|
||||
# image = "${image}/nixos${fileExtension}";
|
||||
# image = "${image}/nixos.img";
|
||||
image = "${machine.config.system.build.image}/${machine.config.boot.uki.name}.raw";
|
||||
};
|
||||
# image = "${image}/nixos${fileExtension}";
|
||||
# image = "${image}/nixos.img";
|
||||
tf-env = pkgs.callPackage ./run/tf-proxmox/tf-env.nix { };
|
||||
proxmox-host = "192.168.51.81"; # root@fediversity-proxmox
|
||||
vm-names = [ "test14" ];
|
||||
|
@ -538,6 +493,8 @@ let
|
|||
pkgs.httpie
|
||||
(pkgs.callPackage ./run/tf-proxmox/tf.nix { inherit sources; })
|
||||
])
|
||||
lib.trace
|
||||
(lib.strings.toJSON environment)
|
||||
''
|
||||
set -xe
|
||||
|
||||
|
@ -556,29 +513,12 @@ let
|
|||
# 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
|
||||
|
||||
qemu-img convert -f raw -O qcow2 -C ${(import nixos_conf).config.system.build.image}/monkey.raw /tmp/disk.qcow2
|
||||
|
||||
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 \
|
||||
env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue