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;
|
inherit (lib.attrsets) genAttrs;
|
||||||
|
|
||||||
## Given a machine's name, make a resource module, except for its missing
|
## Given a machine's name and whether it is a test VM, make a resource module,
|
||||||
## provider. (Depending on the use of that resource, we will provide a
|
## except for its missing provider. (Depending on the use of that resource, we
|
||||||
## different one.)
|
## will provide a different one.)
|
||||||
makeResourceModule = vmName: {
|
makeResourceModule =
|
||||||
_module.args = { inherit inputs; };
|
{ vmName, isTestVm }:
|
||||||
imports = [
|
{
|
||||||
./common/resource.nix
|
_module.args = { inherit inputs; };
|
||||||
(./. + "/${vmName}")
|
imports = [
|
||||||
];
|
./common/resource.nix
|
||||||
fediversityVm.name = vmName;
|
(if isTestVm then ./test-machines + "/${vmName}" else ./machines + "/${vmName}")
|
||||||
};
|
];
|
||||||
|
fediversityVm.name = vmName;
|
||||||
|
};
|
||||||
|
|
||||||
## Given a list of machine names, make a deployment with those machines'
|
## Given a list of machine names, make a deployment with those machines'
|
||||||
## configurations as resources.
|
## configurations as resources.
|
||||||
|
@ -37,7 +39,10 @@ let
|
||||||
type = providers.local.exec;
|
type = providers.local.exec;
|
||||||
imports = [
|
imports = [
|
||||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||||
(makeResourceModule vmName)
|
(makeResourceModule {
|
||||||
|
inherit vmName;
|
||||||
|
isTestVm = false;
|
||||||
|
})
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -55,7 +60,10 @@ let
|
||||||
type = providers.local.exec;
|
type = providers.local.exec;
|
||||||
imports = [
|
imports = [
|
||||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||||
(makeResourceModule vmName)
|
(makeResourceModule {
|
||||||
|
inherit vmName;
|
||||||
|
isTestVm = false;
|
||||||
|
})
|
||||||
{ nixos.module = vmConfig; }
|
{ nixos.module = vmConfig; }
|
||||||
{ nixos.module = self.nixosModules.fediversity; }
|
{ nixos.module = self.nixosModules.fediversity; }
|
||||||
];
|
];
|
||||||
|
@ -78,25 +86,25 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
makeResourceConfig =
|
makeResourceConfig =
|
||||||
vmName:
|
vm:
|
||||||
(evalModules {
|
(evalModules {
|
||||||
modules = [
|
modules = [
|
||||||
nixops4ResourceNixosMockOptions
|
nixops4ResourceNixosMockOptions
|
||||||
(makeResourceModule vmName)
|
(makeResourceModule vm)
|
||||||
];
|
];
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
## Given a VM name, make a NixOS configuration for this machine.
|
## Given a VM name, make a NixOS configuration for this machine.
|
||||||
makeConfiguration =
|
makeConfiguration =
|
||||||
vmName:
|
isTestVm: vmName:
|
||||||
inputs.nixpkgs.lib.nixosSystem {
|
inputs.nixpkgs.lib.nixosSystem {
|
||||||
modules = [
|
modules = [
|
||||||
(makeResourceConfig vmName).nixos.module
|
(makeResourceConfig { inherit vmName isTestVm; }).nixos.module
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
makeVmOptions = vmName: {
|
makeVmOptions = isTestVm: vmName: {
|
||||||
inherit ((makeResourceConfig vmName).fediversityVm)
|
inherit ((makeResourceConfig { inherit vmName isTestVm; }).fediversityVm)
|
||||||
proxmox
|
proxmox
|
||||||
vmId
|
vmId
|
||||||
sockets
|
sockets
|
||||||
|
@ -206,8 +214,10 @@ in
|
||||||
default = makeDeployment machines;
|
default = makeDeployment machines;
|
||||||
test = makeTestDeployment testMachineConfigurations;
|
test = makeTestDeployment testMachineConfigurations;
|
||||||
};
|
};
|
||||||
flake.nixosConfigurations = genAttrs (
|
flake.nixosConfigurations =
|
||||||
machines ++ attrNames testMachineConfigurations
|
genAttrs machines (makeConfiguration false)
|
||||||
) makeConfiguration;
|
// genAttrs (attrNames testMachineConfigurations) (makeConfiguration true);
|
||||||
flake.vmOptions = genAttrs (machines ++ attrNames testMachineConfigurations) makeVmOptions;
|
flake.vmOptions =
|
||||||
|
genAttrs machines (makeVmOptions false)
|
||||||
|
// genAttrs (attrNames testMachineConfigurations) (makeVmOptions true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue