refactor: init hello-world module with unit tests (eval)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./zerotier-redux/flake-module.nix
|
./hello-world/flake-module.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
8
clanServices/hello-world/default.nix
Normal file
8
clanServices/hello-world/default.nix
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{ packages }:
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
_class = "clan.service";
|
||||||
|
manifest.name = "clan-core/hello-word";
|
||||||
|
|
||||||
|
roles.peer = { };
|
||||||
|
}
|
||||||
37
clanServices/hello-world/flake-module.nix
Normal file
37
clanServices/hello-world/flake-module.nix
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
self,
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
module = lib.modules.importApply ./default.nix {
|
||||||
|
inherit (self) packages;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
clan.inventory.modules = {
|
||||||
|
hello-world = module;
|
||||||
|
};
|
||||||
|
perSystem =
|
||||||
|
{ ... }:
|
||||||
|
let
|
||||||
|
# Module that contains the tests
|
||||||
|
# This module adds:
|
||||||
|
# - legacyPackages.<system>.eval-tests-hello-world
|
||||||
|
# - checks.<system>.eval-tests-hello-world
|
||||||
|
unit-test-module = (
|
||||||
|
self.clanLib.test.flakeModules.makeEvalChecks {
|
||||||
|
inherit module;
|
||||||
|
inherit self inputs;
|
||||||
|
testName = "hello-world";
|
||||||
|
tests = ./tests/eval-tests.nix;
|
||||||
|
# Optional arguments passed to the test
|
||||||
|
testArgs = { };
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ unit-test-module ];
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -18,12 +18,12 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Register the module for the test
|
# Register the module for the test
|
||||||
inventory.modules.zerotier-redux = module;
|
inventory.modules.hello-world = module;
|
||||||
|
|
||||||
# Use the module in the test
|
# Use the module in the test
|
||||||
inventory.instances = {
|
inventory.instances = {
|
||||||
"zero" = {
|
"hello" = {
|
||||||
module.name = "zerotier-redux";
|
module.name = "hello-world";
|
||||||
|
|
||||||
roles.peer.machines.jon = { };
|
roles.peer.machines.jon = { };
|
||||||
};
|
};
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{ packages }:
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
_class = "clan.service";
|
|
||||||
manifest.name = "clan-core/zerotier";
|
|
||||||
|
|
||||||
# TODO: Migrate the behavior from nixosModules/clanCore/zerotier
|
|
||||||
# Expose a flag, to disable the clanCore/zerotier module if this module is used
|
|
||||||
# To ensure conflict free behavior
|
|
||||||
roles.moon = { };
|
|
||||||
roles.peer = { };
|
|
||||||
roles.controller = { };
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
self,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inputOverrides = builtins.concatStringsSep " " (
|
|
||||||
builtins.map (input: " --override-input ${input} ${inputs.${input}}") (builtins.attrNames inputs)
|
|
||||||
);
|
|
||||||
|
|
||||||
module = lib.modules.importApply ./default.nix {
|
|
||||||
inherit (self) packages;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
clan.inventory.modules = {
|
|
||||||
zerotier-redux = module;
|
|
||||||
};
|
|
||||||
perSystem =
|
|
||||||
{ system, pkgs, ... }:
|
|
||||||
{
|
|
||||||
legacyPackages.eval-tests-zerotier-redux = import ./tests/eval-tests.nix {
|
|
||||||
inherit lib module;
|
|
||||||
inherit (self) clanLib;
|
|
||||||
};
|
|
||||||
checks = {
|
|
||||||
"eval-tests-zerotier-redux" = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
|
||||||
export HOME="$(realpath .)"
|
|
||||||
|
|
||||||
nix-unit --eval-store "$HOME" \
|
|
||||||
--extra-experimental-features flakes \
|
|
||||||
--show-trace \
|
|
||||||
${inputOverrides} \
|
|
||||||
--flake ${self}#legacyPackages.${system}.eval-tests-zerotier-redux
|
|
||||||
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user