forked from fediversity/fediversity
113 lines
2.9 KiB
Nix
113 lines
2.9 KiB
Nix
{
|
|
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";
|
|
vms = {
|
|
myvm1 = {
|
|
vmid = 100;
|
|
memory = 1024;
|
|
cores = 1;
|
|
sockets = 1;
|
|
kvm = true;
|
|
scsi = [ { file = "local:16"; } ];
|
|
};
|
|
};
|
|
};
|
|
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")
|
|
'';
|
|
}
|