network/nix/nixos-module/default.nix

40 lines
978 B
Nix
Raw Normal View History

2021-04-08 02:35:46 +02:00
# Pulls together NixOS configuration modules according to the
# name/role of the host to be built.
{ hostName, config, lib, pkgs, ... }:
2021-03-19 22:55:48 +01:00
let
inherit (lib) optionals;
2021-03-19 22:55:48 +01:00
2021-03-22 20:25:50 +01:00
hostConfig = lib.config.site.hosts.${hostName};
in {
site = lib.config.site;
2021-03-19 22:55:48 +01:00
imports = [
../lib/config/options.nix
2021-03-24 01:20:30 +01:00
./defaults.nix
2021-03-24 23:37:09 +01:00
./network.nix
2021-04-07 00:01:21 +02:00
./collectd.nix
]
++ optionals (hostConfig.role == "server") [
2021-03-24 01:20:30 +01:00
./server/lxc-containers.nix
./server/network.nix
]
2021-04-04 21:59:17 +02:00
++ optionals (hostName == "server2") [
./server/server2.nix
]
++ optionals (hostConfig.role == "container") [
2021-03-24 01:20:30 +01:00
./container/defaults.nix
./container/dhcp-server.nix
./container/anon.nix
] ++ optionals (
hostConfig.role == "container" &&
lib.config.site.hosts.${hostName}.isRouter
) [
./container/bird.nix
] ++ optionals (builtins.match "upstream.*" hostName != null) [
./container/upstream.nix
] ++ optionals (hostName == "mgmt-gw") [
2021-04-04 22:55:40 +02:00
./container/mgmt-gw.nix
2021-03-19 22:55:48 +01:00
];
}