forked from Fediversity/Fediversity
data model: add TF test #4
17 changed files with 68 additions and 69 deletions
|
@ -34,6 +34,7 @@ in
|
||||||
imports = [
|
imports = [
|
||||||
./options.nix
|
./options.nix
|
||||||
./nixos
|
./nixos
|
||||||
|
./proxmox-qemu-vm.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
## Inject the shared options from the resource's `config` into the NixOS
|
## Inject the shared options from the resource's `config` into the NixOS
|
||||||
|
|
|
@ -17,59 +17,35 @@ let
|
||||||
;
|
;
|
||||||
inherit (lib.attrsets) genAttrs;
|
inherit (lib.attrsets) genAttrs;
|
||||||
|
|
||||||
## Given a machine's name and whether it is a test VM, make a resource module,
|
commonResourceModule = {
|
||||||
## except for its missing provider. (Depending on the use of that resource, we
|
# TODO(@fricklerhandwerk): this is terrible but IMO we should just ditch
|
||||||
## will provide a different one.)
|
# flake-parts and have our own data model for how the project is organised
|
||||||
makeResourceModule =
|
# internally
|
||||||
{ vmName, isTestVm }:
|
_module.args = {
|
||||||
{
|
inherit
|
||||||
# TODO(@fricklerhandwerk): this is terrible but IMO we should just ditch flake-parts and have our own data model for how the project is organised internally
|
inputs
|
||||||
_module.args = {
|
keys
|
||||||
inherit
|
secrets
|
||||||
inputs
|
sources
|
||||||
keys
|
;
|
||||||
secrets
|
|
||||||
sources
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
nixos.module.imports = [
|
|
||||||
## FIXME: It would be preferrable to have those `sources`-related
|
|
||||||
## imports in the modules that use them. However, doing so triggers
|
|
||||||
## infinite recursions because of the way we propagate `sources`.
|
|
||||||
## `sources` must be propagated by means of `specialArgs`, but this
|
|
||||||
## requires a bigger change.
|
|
||||||
"${sources.nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
|
|
||||||
"${sources.agenix}/modules/age.nix"
|
|
||||||
"${sources.disko}/module.nix"
|
|
||||||
"${sources.home-manager}/nixos"
|
|
||||||
|
|
||||||
./common/proxmox-qemu-vm.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
imports =
|
|
||||||
[
|
|
||||||
./common/resource.nix
|
|
||||||
]
|
|
||||||
++ (
|
|
||||||
if isTestVm then
|
|
||||||
[
|
|
||||||
../machines/operator/${vmName}
|
|
||||||
{
|
|
||||||
nixos.module.users.users.root.openssh.authorizedKeys.keys = [
|
|
||||||
# allow our panel vm access to the test machines
|
|
||||||
keys.panel
|
|
||||||
];
|
|
||||||
}
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[
|
|
||||||
../machines/dev/${vmName}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
fediversityVm.name = vmName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
## FIXME: It would be preferrable to have those `sources`-related imports in
|
||||||
|
## the modules that use them. However, doing so triggers infinite recursions
|
||||||
|
## because of the way we propagate `sources`. `sources` must be propagated by
|
||||||
|
## means of `specialArgs`, but this requires a bigger change.
|
||||||
|
nixos.module.imports = [
|
||||||
|
"${sources.nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
|
||||||
|
"${sources.agenix}/modules/age.nix"
|
||||||
|
"${sources.disko}/module.nix"
|
||||||
|
"${sources.home-manager}/nixos"
|
||||||
|
];
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./common/resource.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
## 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.
|
||||||
makeDeployment =
|
makeDeployment =
|
||||||
|
@ -81,10 +57,8 @@ let
|
||||||
type = providers.local.exec;
|
type = providers.local.exec;
|
||||||
imports = [
|
imports = [
|
||||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||||
(makeResourceModule {
|
commonResourceModule
|
||||||
inherit vmName;
|
../machines/dev/${vmName}
|
||||||
isTestVm = false;
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -101,21 +75,29 @@ let
|
||||||
fediversity = import ../services/fediversity;
|
fediversity = import ../services/fediversity;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
garageConfigurationResource = makeResourceModule {
|
garageConfigurationResource = {
|
||||||
vmName = "test01";
|
imports = [
|
||||||
isTestVm = true;
|
commonResourceModule
|
||||||
|
../machines/operator/test01
|
||||||
|
];
|
||||||
};
|
};
|
||||||
mastodonConfigurationResource = makeResourceModule {
|
mastodonConfigurationResource = {
|
||||||
vmName = "test06"; # somehow `test02` has a problem - use test06 instead
|
imports = [
|
||||||
isTestVm = true;
|
commonResourceModule
|
||||||
|
../machines/operator/test06 # somehow `test02` has a problem - use test06 instead
|
||||||
|
];
|
||||||
};
|
};
|
||||||
peertubeConfigurationResource = makeResourceModule {
|
peertubeConfigurationResource = {
|
||||||
vmName = "test05";
|
imports = [
|
||||||
isTestVm = true;
|
commonResourceModule
|
||||||
|
../machines/operator/test05
|
||||||
|
];
|
||||||
};
|
};
|
||||||
pixelfedConfigurationResource = makeResourceModule {
|
pixelfedConfigurationResource = {
|
||||||
vmName = "test04";
|
imports = [
|
||||||
isTestVm = true;
|
commonResourceModule
|
||||||
|
../machines/operator/test04
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,11 +117,12 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
makeResourceConfig =
|
makeResourceConfig =
|
||||||
vm:
|
{ vmName, isTestVm }:
|
||||||
(evalModules {
|
(evalModules {
|
||||||
modules = [
|
modules = [
|
||||||
nixops4ResourceNixosMockOptions
|
nixops4ResourceNixosMockOptions
|
||||||
(makeResourceModule vm)
|
commonResourceModule
|
||||||
|
(if isTestVm then ../machines/operator/${vmName} else ../machines/dev/${vmName})
|
||||||
];
|
];
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "fedi200";
|
||||||
vmId = 200;
|
vmId = 200;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
description = "Testing machine for Hans";
|
description = "Testing machine for Hans";
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "fedi201";
|
||||||
vmId = 201;
|
vmId = 201;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
description = "FediPanel";
|
description = "FediPanel";
|
||||||
|
|
|
@ -20,6 +20,7 @@ in
|
||||||
ssh.host = mkForce "forgejo-ci";
|
ssh.host = mkForce "forgejo-ci";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "forgejo-ci";
|
||||||
domain = "procolix.com";
|
domain = "procolix.com";
|
||||||
|
|
||||||
ipv4 = {
|
ipv4 = {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "vm02116";
|
||||||
vmId = 2116;
|
vmId = 2116;
|
||||||
proxmox = "procolix";
|
proxmox = "procolix";
|
||||||
description = "Forgejo";
|
description = "Forgejo";
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "vm02187";
|
||||||
vmId = 2187;
|
vmId = 2187;
|
||||||
proxmox = "procolix";
|
proxmox = "procolix";
|
||||||
description = "Wiki";
|
description = "Wiki";
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test01";
|
||||||
vmId = 7001;
|
vmId = 7001;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test02";
|
||||||
vmId = 7002;
|
vmId = 7002;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test03";
|
||||||
vmId = 7003;
|
vmId = 7003;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test04";
|
||||||
vmId = 7004;
|
vmId = 7004;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test05";
|
||||||
vmId = 7005;
|
vmId = 7005;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test06";
|
||||||
vmId = 7006;
|
vmId = 7006;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test11";
|
||||||
vmId = 7011;
|
vmId = 7011;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test12";
|
||||||
vmId = 7012;
|
vmId = 7012;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test13";
|
||||||
vmId = 7013;
|
vmId = 7013;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
_class = "nixops4Resource";
|
_class = "nixops4Resource";
|
||||||
|
|
||||||
fediversityVm = {
|
fediversityVm = {
|
||||||
|
name = "test14";
|
||||||
vmId = 7014;
|
vmId = 7014;
|
||||||
proxmox = "fediversity";
|
proxmox = "fediversity";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue