One deployment per machine; bundle test machines
This commit is contained in:
parent
bc8ad08228
commit
f6960010cd
2 changed files with 58 additions and 86 deletions
|
@ -96,23 +96,6 @@ nixops4 apply
|
||||||
|
|
||||||
See `infra/proxmox-remove.sh --help`.
|
See `infra/proxmox-remove.sh --help`.
|
||||||
|
|
||||||
## Deployments
|
|
||||||
|
|
||||||
default
|
|
||||||
: Contains everything
|
|
||||||
|
|
||||||
`git`
|
|
||||||
: Machines hosting our Git infrastructure, eg. Forgejo and its actions runners
|
|
||||||
|
|
||||||
`web`
|
|
||||||
: Machines hosting our online content, eg. the website or the wiki
|
|
||||||
|
|
||||||
`other`
|
|
||||||
: Machines without a specific purpose
|
|
||||||
|
|
||||||
`hans`
|
|
||||||
: Testing machines for Hans's work
|
|
||||||
|
|
||||||
## Machines
|
## Machines
|
||||||
|
|
||||||
These machines are hosted on the Procolix Proxmox instance,
|
These machines are hosted on the Procolix Proxmox instance,
|
||||||
|
|
|
@ -5,18 +5,12 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib) mkOption evalModules;
|
||||||
attrValues
|
inherit (lib.attrsets) genAttrs;
|
||||||
concatLists
|
|
||||||
mapAttrs
|
|
||||||
mkOption
|
|
||||||
evalModules
|
|
||||||
;
|
|
||||||
inherit (lib.attrsets) concatMapAttrs genAttrs;
|
|
||||||
|
|
||||||
addDefaultDeployment =
|
|
||||||
deployments: deployments // { default = concatLists (attrValues deployments); };
|
|
||||||
|
|
||||||
|
## Given a machine's name, make a resource module, except for its missing
|
||||||
|
## provider. (Depending on the use of that resource, we will provide a
|
||||||
|
## different one.)
|
||||||
makeResourceModule = vmName: {
|
makeResourceModule = vmName: {
|
||||||
_module.args = { inherit inputs; };
|
_module.args = { inherit inputs; };
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -26,8 +20,10 @@ let
|
||||||
fediversityVm.name = vmName;
|
fediversityVm.name = vmName;
|
||||||
};
|
};
|
||||||
|
|
||||||
makeDeployments = mapAttrs (
|
## Given a list of machine names, make a deployment with those machines'
|
||||||
_: vmNames:
|
## configurations as resources
|
||||||
|
makeDeployment =
|
||||||
|
vmNames:
|
||||||
{ providers, ... }:
|
{ providers, ... }:
|
||||||
{
|
{
|
||||||
providers.local = inputs.nixops4.modules.nixops4Provider.local;
|
providers.local = inputs.nixops4.modules.nixops4Provider.local;
|
||||||
|
@ -38,8 +34,8 @@ let
|
||||||
(makeResourceModule vmName)
|
(makeResourceModule vmName)
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
);
|
makeDeployment' = vmName: makeDeployment [ vmName ];
|
||||||
|
|
||||||
nixops4ResourceNixosMockOptions = {
|
nixops4ResourceNixosMockOptions = {
|
||||||
## NOTE: We allow the use of a few options from
|
## NOTE: We allow the use of a few options from
|
||||||
|
@ -65,65 +61,58 @@ let
|
||||||
];
|
];
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
makeConfigurations = concatMapAttrs (
|
## Given a VM name, make a NixOS configuration for this machine.
|
||||||
_: vmNames:
|
makeConfiguration =
|
||||||
genAttrs vmNames (
|
vmName:
|
||||||
vmName:
|
inputs.nixpkgs.lib.nixosSystem {
|
||||||
inputs.nixpkgs.lib.nixosSystem {
|
modules = [
|
||||||
modules = [
|
(makeResourceConfig vmName).nixos.module
|
||||||
(makeResourceConfig vmName).nixos.module
|
];
|
||||||
];
|
};
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
makeVmOptions = concatMapAttrs (
|
makeVmOptions = vmName: {
|
||||||
_: vmNames:
|
inherit ((makeResourceConfig vmName).fediversityVm)
|
||||||
genAttrs vmNames (vmName: {
|
proxmox
|
||||||
inherit ((makeResourceConfig vmName).fediversityVm)
|
vmId
|
||||||
proxmox
|
sockets
|
||||||
vmId
|
cores
|
||||||
sockets
|
memory
|
||||||
cores
|
hostPublicKey
|
||||||
memory
|
unsafeHostPrivateKey
|
||||||
hostPublicKey
|
;
|
||||||
unsafeHostPrivateKey
|
|
||||||
;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
machines = {
|
|
||||||
git = [
|
|
||||||
"vm02116"
|
|
||||||
];
|
|
||||||
web = [ "vm02187" ];
|
|
||||||
other = [
|
|
||||||
"vm02179"
|
|
||||||
"vm02186"
|
|
||||||
];
|
|
||||||
hans = [
|
|
||||||
"fedi200"
|
|
||||||
];
|
|
||||||
kiara = [
|
|
||||||
"fedi201"
|
|
||||||
];
|
|
||||||
test = [
|
|
||||||
"test01"
|
|
||||||
"test02"
|
|
||||||
"test03"
|
|
||||||
"test04"
|
|
||||||
"test05"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
machines = [
|
||||||
|
"vm02116"
|
||||||
|
"vm02179"
|
||||||
|
"vm02186"
|
||||||
|
"vm02187"
|
||||||
|
|
||||||
|
"fedi200"
|
||||||
|
"fedi201"
|
||||||
|
];
|
||||||
|
|
||||||
|
testMachines = [
|
||||||
|
"test01"
|
||||||
|
"test02"
|
||||||
|
"test03"
|
||||||
|
"test04"
|
||||||
|
"test05"
|
||||||
|
];
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.lib.makeInstallerIso = import ./makeInstallerIso.nix;
|
flake.lib.makeInstallerIso = import ./makeInstallerIso.nix;
|
||||||
|
|
||||||
## REVIEW: It would probably make more sense to have the VM names as parent of
|
## - Each normal or test machine gets a NixOS configuration.
|
||||||
## the corresponding resource, NixOS configuration, and VM options, rather
|
## - Each normal or test machine gets a VM options entry.
|
||||||
## than the contrary.
|
## - Each normal machine gets a deployment.
|
||||||
nixops4Deployments = makeDeployments (addDefaultDeployment machines);
|
## - We add a “default” deployment with all normal machines.
|
||||||
flake.nixosConfigurations = makeConfigurations machines;
|
## - We add a “test” deployment with all test machines.
|
||||||
flake.vmOptions = makeVmOptions machines;
|
nixops4Deployments = genAttrs machines makeDeployment' // {
|
||||||
|
default = makeDeployment machines;
|
||||||
|
test = makeDeployment testMachines;
|
||||||
|
};
|
||||||
|
flake.nixosConfigurations = genAttrs (machines ++ testMachines) makeConfiguration;
|
||||||
|
flake.vmOptions = genAttrs (machines ++ testMachines) makeVmOptions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue