49 lines
1.1 KiB
Nix
49 lines
1.1 KiB
Nix
# tests/networkd-phobos.nix
|
|
let
|
|
system = "x86_64-linux";
|
|
|
|
# Real nixpkgs for addressing lib
|
|
pkgs = import <nixpkgs> { inherit system; };
|
|
realLib = pkgs.lib;
|
|
|
|
# Minimal "testing lib" that makes mkIf actually behave like a real if
|
|
testLib = realLib // {
|
|
mkOption = x: x;
|
|
mkIf = cond: body: if cond then body else { };
|
|
|
|
types = {
|
|
str = "str";
|
|
nullOr = t: "nullOr " + builtins.toString t;
|
|
};
|
|
};
|
|
|
|
# Your world + addressing lib
|
|
meta = import ../meta.nix;
|
|
addressing = import ../lib/addressing { lib = realLib; };
|
|
|
|
network = addressing.mkNetworkFromSpec meta;
|
|
|
|
# Fake NixOS config for this test
|
|
config = {
|
|
networking.hostName = "phobos";
|
|
metanix = {
|
|
thisHost = "phobos";
|
|
inherit network;
|
|
};
|
|
};
|
|
|
|
# Call the Metanix networkd module with the fake lib + config
|
|
networkdModule = import ../modules/metanix/networkd.nix {
|
|
lib = testLib;
|
|
inherit config;
|
|
};
|
|
|
|
in
|
|
{
|
|
# Raw Metanix view for sanity
|
|
metanixHost = network.hosts.phobos;
|
|
metanixSubnet = network.subnets."home-main";
|
|
|
|
# What the module actually emits once mkIf is forced
|
|
systemdNetwork = networkdModule.config.systemd.network;
|
|
}
|