Still a work in progress.
This commit is contained in:
parent
500eb9e859
commit
62899898fe
5 changed files with 42 additions and 75 deletions
|
|
@ -2,49 +2,35 @@
|
|||
let
|
||||
system = "x86_64-linux";
|
||||
|
||||
# Bring in nixpkgs and lib
|
||||
# Grab nixpkgs lib for convenience
|
||||
pkgs = import <nixpkgs> { inherit system; };
|
||||
lib = pkgs.lib;
|
||||
|
||||
# Your world + addressing lib
|
||||
# Metanix world + addressing
|
||||
meta = import ../meta.nix;
|
||||
addressing = import ../lib/addressing { inherit lib; };
|
||||
|
||||
# NixOS module system library
|
||||
nixosLib = import <nixpkgs/nixos/lib> {
|
||||
inherit lib;
|
||||
network = addressing.mkNetworkFromSpec meta;
|
||||
|
||||
# Fake NixOS config that your module expects
|
||||
config = {
|
||||
networking.hostName = "phobos";
|
||||
metanix = {
|
||||
thisHost = "phobos";
|
||||
inherit network;
|
||||
};
|
||||
};
|
||||
|
||||
# All standard NixOS modules (as a list)
|
||||
baseModules = import <nixpkgs/nixos/modules/module-list.nix>;
|
||||
|
||||
# Evaluate modules as if this were a NixOS system
|
||||
evalResult = nixosLib.evalModules {
|
||||
modules =
|
||||
baseModules
|
||||
++ [
|
||||
# Metanix core wiring (meta + addressing)
|
||||
../modules/metanix/core.nix
|
||||
|
||||
# systemd-networkd integration
|
||||
../modules/metanix/networkd.nix
|
||||
|
||||
# Local stub: "this machine is phobos"
|
||||
{
|
||||
networking.hostName = "phobos";
|
||||
metanix.thisHost = "phobos";
|
||||
}
|
||||
];
|
||||
|
||||
# Args passed to all modules: { lib, pkgs, system, meta, addressing, modulesPath, ... }
|
||||
specialArgs = {
|
||||
inherit lib pkgs system meta addressing;
|
||||
modulesPath = builtins.toString <nixpkgs/nixos/modules>;
|
||||
};
|
||||
# Call the networkd module directly as a function
|
||||
networkdModule = import ../modules/metanix/networkd.nix {
|
||||
inherit lib config;
|
||||
};
|
||||
in
|
||||
{
|
||||
systemdNetwork = evalResult.config.systemd.network;
|
||||
metanixHost = evalResult.config.metanix.network.hosts.phobos;
|
||||
metanixSubnet = evalResult.config.metanix.network.subnets."home-main";
|
||||
# Raw Metanix view
|
||||
metanixHost = network.hosts.phobos;
|
||||
metanixSubnet = network.subnets."home-main";
|
||||
|
||||
# What the module actually emits
|
||||
systemdNetwork = networkdModule.config.systemd.network;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue