forked from Fediversity/Fediversity
closes #93. note that this includes classes: - `nixos` - `nixosTest` - `nixops4Resource` - `nixops4Deployment` .. and my (made-up, as per the [docs](https://ryantm.github.io/nixpkgs/module-system/module-system/#module-system-lib-evalModules-param-class)): - `nix-unit` - `package` .. while i did not manage to cover: - service tests, given `pkgs.nixosTest` seemed to not actually like `_class = "nixosTest"` (?!) ... nor #93's mentioned destructured arguments for that matter, as per Fediversity/Fediversity#93 (comment) - let me know if that is still desired as well. Reviewed-on: Fediversity/Fediversity#398 Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Kiara Grouwstra <kiara@procolix.eu> Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
89 lines
1.9 KiB
Nix
89 lines
1.9 KiB
Nix
{
|
|
self,
|
|
inputs,
|
|
lib,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (builtins) fromJSON readFile listToAttrs;
|
|
|
|
targetMachines = [
|
|
"garage"
|
|
"mastodon"
|
|
"peertube"
|
|
"pixelfed"
|
|
];
|
|
pathToRoot = /. + (builtins.unsafeDiscardStringContext self);
|
|
pathFromRoot = ./.;
|
|
enableAcme = true;
|
|
|
|
in
|
|
{
|
|
_class = "flake";
|
|
|
|
perSystem =
|
|
{ pkgs, ... }:
|
|
{
|
|
checks.deployment-cli = pkgs.testers.runNixOSTest {
|
|
imports = [
|
|
../common/nixosTest.nix
|
|
./nixosTest.nix
|
|
];
|
|
_module.args.inputs = inputs;
|
|
inherit
|
|
targetMachines
|
|
pathToRoot
|
|
pathFromRoot
|
|
enableAcme
|
|
;
|
|
};
|
|
};
|
|
|
|
nixops4Deployments =
|
|
let
|
|
makeTargetResource = nodeName: {
|
|
imports = [ ../common/targetResource.nix ];
|
|
_module.args.inputs = inputs;
|
|
inherit
|
|
nodeName
|
|
pathToRoot
|
|
pathFromRoot
|
|
enableAcme
|
|
;
|
|
};
|
|
|
|
## The deployment function - what we are here to test!
|
|
##
|
|
## TODO: Modularise `deployment/default.nix` to get rid of the nested
|
|
## function calls.
|
|
makeTestDeployment =
|
|
args:
|
|
(import ../..)
|
|
{
|
|
inherit lib;
|
|
inherit (inputs) nixops4 nixops4-nixos;
|
|
fediversity = import ../../../services/fediversity;
|
|
}
|
|
(listToAttrs (
|
|
map (nodeName: {
|
|
name = "${nodeName}ConfigurationResource";
|
|
value = makeTargetResource nodeName;
|
|
}) targetMachines
|
|
))
|
|
(fromJSON (readFile ../../configuration.sample.json) // args);
|
|
|
|
in
|
|
{
|
|
check-deployment-cli-nothing = makeTestDeployment { };
|
|
|
|
check-deployment-cli-mastodon-pixelfed = makeTestDeployment {
|
|
mastodon.enable = true;
|
|
pixelfed.enable = true;
|
|
};
|
|
|
|
check-deployment-cli-peertube = makeTestDeployment {
|
|
peertube.enable = true;
|
|
};
|
|
};
|
|
}
|