forked from Fediversity/Fediversity
Split machine definitions into subdirectories
This commit is contained in:
parent
3f9c174d97
commit
c74145fe24
24 changed files with 33 additions and 23 deletions
infra
flake-part.nix
machines
fedi200
fedi201
vm02116
vm02179
vm02186
vm02187
test-machines
test01
test02
test03
test04
test05
|
@ -14,17 +14,19 @@ let
|
|||
;
|
||||
inherit (lib.attrsets) genAttrs;
|
||||
|
||||
## 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: {
|
||||
_module.args = { inherit inputs; };
|
||||
imports = [
|
||||
./common/resource.nix
|
||||
(./. + "/${vmName}")
|
||||
];
|
||||
fediversityVm.name = vmName;
|
||||
};
|
||||
## Given a machine's name and whether it is a test VM, make a resource module,
|
||||
## except for its missing provider. (Depending on the use of that resource, we
|
||||
## will provide a different one.)
|
||||
makeResourceModule =
|
||||
{ vmName, isTestVm }:
|
||||
{
|
||||
_module.args = { inherit inputs; };
|
||||
imports = [
|
||||
./common/resource.nix
|
||||
(if isTestVm then ./test-machines + "/${vmName}" else ./machines + "/${vmName}")
|
||||
];
|
||||
fediversityVm.name = vmName;
|
||||
};
|
||||
|
||||
## Given a list of machine names, make a deployment with those machines'
|
||||
## configurations as resources.
|
||||
|
@ -37,7 +39,10 @@ let
|
|||
type = providers.local.exec;
|
||||
imports = [
|
||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||
(makeResourceModule vmName)
|
||||
(makeResourceModule {
|
||||
inherit vmName;
|
||||
isTestVm = false;
|
||||
})
|
||||
];
|
||||
});
|
||||
};
|
||||
|
@ -55,7 +60,10 @@ let
|
|||
type = providers.local.exec;
|
||||
imports = [
|
||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||
(makeResourceModule vmName)
|
||||
(makeResourceModule {
|
||||
inherit vmName;
|
||||
isTestVm = false;
|
||||
})
|
||||
{ nixos.module = vmConfig; }
|
||||
{ nixos.module = self.nixosModules.fediversity; }
|
||||
];
|
||||
|
@ -78,25 +86,25 @@ let
|
|||
};
|
||||
|
||||
makeResourceConfig =
|
||||
vmName:
|
||||
vm:
|
||||
(evalModules {
|
||||
modules = [
|
||||
nixops4ResourceNixosMockOptions
|
||||
(makeResourceModule vmName)
|
||||
(makeResourceModule vm)
|
||||
];
|
||||
}).config;
|
||||
|
||||
## Given a VM name, make a NixOS configuration for this machine.
|
||||
makeConfiguration =
|
||||
vmName:
|
||||
isTestVm: vmName:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
(makeResourceConfig vmName).nixos.module
|
||||
(makeResourceConfig { inherit vmName isTestVm; }).nixos.module
|
||||
];
|
||||
};
|
||||
|
||||
makeVmOptions = vmName: {
|
||||
inherit ((makeResourceConfig vmName).fediversityVm)
|
||||
makeVmOptions = isTestVm: vmName: {
|
||||
inherit ((makeResourceConfig { inherit vmName isTestVm; }).fediversityVm)
|
||||
proxmox
|
||||
vmId
|
||||
sockets
|
||||
|
@ -206,8 +214,10 @@ in
|
|||
default = makeDeployment machines;
|
||||
test = makeTestDeployment testMachineConfigurations;
|
||||
};
|
||||
flake.nixosConfigurations = genAttrs (
|
||||
machines ++ attrNames testMachineConfigurations
|
||||
) makeConfiguration;
|
||||
flake.vmOptions = genAttrs (machines ++ attrNames testMachineConfigurations) makeVmOptions;
|
||||
flake.nixosConfigurations =
|
||||
genAttrs machines (makeConfiguration false)
|
||||
// genAttrs (attrNames testMachineConfigurations) (makeConfiguration true);
|
||||
flake.vmOptions =
|
||||
genAttrs machines (makeVmOptions false)
|
||||
// genAttrs (attrNames testMachineConfigurations) (makeVmOptions true);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue