Fediversity/infra/flake-part.nix
Nicolas “Niols” Jeannerod c74fc4f927 Add VM for the front-end (#183)
For now, I created yet another deployment. Basically, this seems to tell me that we only ever use:

- one deployment per machine (when we change its configuration)
- one big deployment for all of them (eg. for nixpkgs updates or new contributor)

but that the current split into themes doesn't really work. I can discontinue it in another PR.

`fedi201` is accessible under `fedi201.abundos.eu`. Its configuration lives in `infra/fedi201/default.nix`. This Nix file is a NixOps4 resource module, not a NixOS configuration module; you probably want to add a `nixos.module` field to it where you put your NixOS configuration.

Reviewed-on: Fediversity/Fediversity#183
Reviewed-by: kiara Grouwstra <kiara@procolix.eu>
Co-authored-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
Co-committed-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
2025-02-24 14:49:53 +01:00

100 lines
2.2 KiB
Nix

{
inputs,
lib,
...
}:
let
inherit (lib)
attrValues
concatLists
mapAttrs
mkOption
evalModules
;
inherit (lib.attrsets) concatMapAttrs genAttrs;
addDefaultDeployment =
deployments: deployments // { default = concatLists (attrValues deployments); };
makeResourceModule = vmName: {
_module.args = { inherit inputs; };
imports = [
./common/resource.nix
(./. + "/${vmName}")
];
fediversityVm.name = vmName;
};
makeDeployments = mapAttrs (
_: vmNames:
{ providers, ... }:
{
providers.local = inputs.nixops4.modules.nixops4Provider.local;
resources = genAttrs vmNames (vmName: {
type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
(makeResourceModule vmName)
];
});
}
);
nixops4ResourceNixosMockOptions = {
## NOTE: We allow the use of a few options from
## `inputs.nixops4-nixos.modules.nixops4Resource.nixos` such that we can
## reuse modules that make use of them.
##
## REVIEW: We can probably do much better and cleaner. On the other hand,
## this is only needed to expose NixOS configurations for provisioning
## purposes, and eventually all of this should be handled by NixOps4.
options = {
nixos.module = mkOption { }; # NOTE: not just `nixos` otherwise merging will go wrong
nixpkgs = mkOption { };
ssh = mkOption { };
};
};
makeConfigurations = concatMapAttrs (
_: vmNames:
genAttrs vmNames (
vmName:
inputs.nixpkgs.lib.nixosSystem {
modules = [
(evalModules {
modules = [
nixops4ResourceNixosMockOptions
(makeResourceModule vmName)
];
}).config.nixos.module
];
}
)
);
machines = {
git = [
"vm02116"
"fedi300"
];
web = [ "vm02187" ];
other = [
"vm02179"
"vm02186"
];
hans = [
"fedi200"
];
kiara = [
"fedi201"
];
};
in
{
flake.lib.makeInstallerIso = import ./makeInstallerIso.nix;
nixops4Deployments = makeDeployments (addDefaultDeployment machines);
flake.nixosConfigurations = makeConfigurations machines;
}