forked from zentralwerk/network
nixosConfiguration with infinite recursion
This commit is contained in:
parent
84723105f3
commit
a39bad4f85
36
flake.nix
36
flake.nix
|
@ -11,6 +11,15 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
systems = [ system ];
|
systems = [ system ];
|
||||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
|
|
||||||
|
nixosConfig = name:
|
||||||
|
nixpkgs.lib.nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
modules = [ self.nixosModule ];
|
||||||
|
extraModules = [ ({ ... }: {
|
||||||
|
networking.hostName = name;
|
||||||
|
}) ];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
lib =
|
lib =
|
||||||
|
@ -27,19 +36,20 @@
|
||||||
imports = [ ./nix/nixos-module ];
|
imports = [ ./nix/nixos-module ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosConfigurations.test_vm =
|
nixosConfigurations =
|
||||||
nixpkgs.lib.nixosSystem {
|
builtins.mapAttrs (hostName: _: nixosConfig hostName) (
|
||||||
inherit system;
|
nixpkgs.lib.filterAttrs (_: { role, ... }:
|
||||||
modules = [ nixosModule ];
|
builtins.elem role [ "server" "container" ]
|
||||||
extraModules = [ ({ ... }: {
|
) lib.config.site.hosts
|
||||||
networking.hostName = "test_vm";
|
);
|
||||||
}) ];
|
|
||||||
};
|
|
||||||
|
|
||||||
nixosConfigurations.server1 =
|
# nixosConfigurations.test_vm =
|
||||||
nixpkgs.lib.nixosSystem {
|
# nixpkgs.lib.nixosSystem {
|
||||||
inherit system;
|
# inherit system;
|
||||||
modules = [];
|
# modules = [ nixosModule ];
|
||||||
};
|
# extraModules = [ ({ ... }: {
|
||||||
|
# networking.hostName = "test_vm";
|
||||||
|
# }) ];
|
||||||
|
# };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,15 @@ let
|
||||||
inherit self pkgs;
|
inherit self pkgs;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
./options.nix
|
|
||||||
./legacy.nix
|
|
||||||
(
|
(
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
{
|
{
|
||||||
|
options.warnings = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
options.gpgKey = mkOption {
|
options.gpgKey = mkOption {
|
||||||
type = with types; nullOr path;
|
type = with types; nullOr path;
|
||||||
};
|
};
|
||||||
|
@ -23,6 +26,8 @@ let
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
./options.nix
|
||||||
|
./legacy.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, ... }:
|
{ config, options, lib, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
|
@ -48,12 +48,6 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.warnings = mkOption {
|
|
||||||
type = types.listOf types.str;
|
|
||||||
default = [];
|
|
||||||
internal = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
options.site = {
|
options.site = {
|
||||||
net = mkOption {
|
net = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
{ config, lib, ... }:
|
{ self, config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.networking) hostName;
|
inherit (config.networking) hostName;
|
||||||
inherit (lib) optional;
|
inherit (lib) optional;
|
||||||
|
|
||||||
hostConfig = config.site.hosts.${hostName};
|
hostConfig = self.lib.config.site.hosts.${hostName};
|
||||||
in
|
in
|
||||||
{
|
builtins.trace (lib.generators.toPretty {} self.lib.config) {
|
||||||
imports = [
|
imports = [
|
||||||
|
#{ config = self.lib.config; }
|
||||||
./defaults.nix
|
./defaults.nix
|
||||||
]
|
../lib/config/options.nix
|
||||||
++ optional (hostConfig.role == "server") [
|
|
||||||
./lxc-containers.nix
|
|
||||||
]
|
|
||||||
++ optional (hostConfig.role == "container") [
|
|
||||||
./container.nix
|
|
||||||
];
|
];
|
||||||
|
# ++ optional (hostConfig.role == "server") [
|
||||||
|
# #./lxc-containers.nix
|
||||||
|
# ]
|
||||||
|
# ++ optional (hostConfig.role == "container") [
|
||||||
|
# ./container.nix
|
||||||
|
# ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue