This reverts commit e7c6333e06.
The propagated `self` attribute can be an error in non `flake-parts`
modules.
152 lines
2.9 KiB
Nix
152 lines
2.9 KiB
Nix
{
|
|
lib,
|
|
nixpkgs,
|
|
clan-core,
|
|
buildClan,
|
|
...
|
|
}:
|
|
let
|
|
evalClan = import ./eval.nix {
|
|
inherit lib nixpkgs clan-core;
|
|
self = ./.;
|
|
};
|
|
in
|
|
#######
|
|
{
|
|
test_only_required =
|
|
let
|
|
config = evalClan { directory = ./.; };
|
|
in
|
|
{
|
|
expr = config.pkgsForSystem null == null;
|
|
expected = true;
|
|
};
|
|
|
|
test_all_simple =
|
|
let
|
|
config = evalClan {
|
|
directory = ./.;
|
|
machines = { };
|
|
inventory = {
|
|
meta.name = "test";
|
|
};
|
|
pkgsForSystem = _system: { };
|
|
};
|
|
in
|
|
{
|
|
expr = config ? inventory;
|
|
expected = true;
|
|
};
|
|
|
|
test_outputs_clanInternals =
|
|
let
|
|
config = evalClan {
|
|
imports = [
|
|
# What the user needs to specif
|
|
{
|
|
directory = ./.;
|
|
inventory.meta.name = "test";
|
|
}
|
|
|
|
./module.nix
|
|
# Explicit output, usually defined by flake-parts
|
|
{ options.nixosConfigurations = lib.mkOption { type = lib.types.raw; }; }
|
|
];
|
|
};
|
|
in
|
|
{
|
|
expr = config.clanInternals.meta;
|
|
expected = {
|
|
description = null;
|
|
icon = null;
|
|
name = "test";
|
|
};
|
|
};
|
|
|
|
test_fn_simple =
|
|
let
|
|
result = buildClan {
|
|
directory = ./.;
|
|
meta.name = "test";
|
|
};
|
|
in
|
|
{
|
|
expr = result.clanInternals.meta;
|
|
expected = {
|
|
description = null;
|
|
icon = null;
|
|
name = "test";
|
|
};
|
|
};
|
|
|
|
test_fn_extensiv_meta =
|
|
let
|
|
result = buildClan {
|
|
directory = ./.;
|
|
meta.name = "test";
|
|
meta.description = "test";
|
|
meta.icon = "test";
|
|
inventory.meta.name = "superclan";
|
|
inventory.meta.description = "description";
|
|
inventory.meta.icon = "icon";
|
|
};
|
|
in
|
|
{
|
|
expr = result.clanInternals.meta;
|
|
expected = {
|
|
description = "description";
|
|
icon = "icon";
|
|
name = "superclan";
|
|
};
|
|
};
|
|
|
|
test_fn_clan_core =
|
|
let
|
|
result = buildClan {
|
|
directory = ../../.;
|
|
meta.name = "test-clan-core";
|
|
};
|
|
in
|
|
{
|
|
expr = builtins.attrNames result.nixosConfigurations;
|
|
expected = [ "test-inventory-machine" ];
|
|
};
|
|
|
|
test_buildClan_all_machines =
|
|
let
|
|
result = buildClan {
|
|
directory = ./.;
|
|
meta.name = "test";
|
|
inventory.machines.machine1.meta.name = "machine1";
|
|
|
|
machines.machine2 = { };
|
|
|
|
};
|
|
in
|
|
{
|
|
expr = builtins.attrNames result.nixosConfigurations;
|
|
expected = [
|
|
"machine1"
|
|
"machine2"
|
|
];
|
|
};
|
|
|
|
test_buildClan_specialArgs =
|
|
let
|
|
result = buildClan {
|
|
directory = ./.;
|
|
meta.name = "test";
|
|
specialArgs.foo = "dream2nix";
|
|
machines.machine2 =
|
|
{ foo, ... }:
|
|
{
|
|
networking.hostName = foo;
|
|
};
|
|
};
|
|
in
|
|
{
|
|
expr = result.nixosConfigurations.machine2.config.networking.hostName;
|
|
expected = "dream2nix";
|
|
};
|
|
}
|