diff --git a/flake.nix b/flake.nix index e860b42..a25d2ca 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,15 @@ system = "x86_64-linux"; systems = [ system ]; forAllSystems = nixpkgs.lib.genAttrs systems; + + nixosConfig = name: + nixpkgs.lib.nixosSystem { + inherit system; + modules = [ self.nixosModule ]; + extraModules = [ ({ ... }: { + networking.hostName = name; + }) ]; + }; in rec { lib = @@ -27,19 +36,20 @@ imports = [ ./nix/nixos-module ]; }; - nixosConfigurations.test_vm = - nixpkgs.lib.nixosSystem { - inherit system; - modules = [ nixosModule ]; - extraModules = [ ({ ... }: { - networking.hostName = "test_vm"; - }) ]; - }; + nixosConfigurations = + builtins.mapAttrs (hostName: _: nixosConfig hostName) ( + nixpkgs.lib.filterAttrs (_: { role, ... }: + builtins.elem role [ "server" "container" ] + ) lib.config.site.hosts + ); - nixosConfigurations.server1 = - nixpkgs.lib.nixosSystem { - inherit system; - modules = []; - }; + # nixosConfigurations.test_vm = + # nixpkgs.lib.nixosSystem { + # inherit system; + # modules = [ nixosModule ]; + # extraModules = [ ({ ... }: { + # networking.hostName = "test_vm"; + # }) ]; + # }; }; } diff --git a/nix/lib/config/default.nix b/nix/lib/config/default.nix index cacdf3b..1f65963 100644 --- a/nix/lib/config/default.nix +++ b/nix/lib/config/default.nix @@ -9,12 +9,15 @@ let inherit self pkgs; }; modules = [ - ./options.nix - ./legacy.nix ( { lib, ... }: with lib; { + options.warnings = mkOption { + type = types.listOf types.str; + default = []; + internal = true; + }; options.gpgKey = mkOption { type = with types; nullOr path; }; @@ -23,6 +26,8 @@ let }; } ) + ./options.nix + ./legacy.nix ]; }; in diff --git a/nix/lib/config/options.nix b/nix/lib/config/options.nix index 4b941ea..00d3d5b 100644 --- a/nix/lib/config/options.nix +++ b/nix/lib/config/options.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, options, lib, ... }: with lib; let @@ -48,12 +48,6 @@ let }; in { - options.warnings = mkOption { - type = types.listOf types.str; - default = []; - internal = true; - }; - options.site = { net = mkOption { default = {}; diff --git a/nix/nixos-module/default.nix b/nix/nixos-module/default.nix index 2cbba79..63d3c81 100644 --- a/nix/nixos-module/default.nix +++ b/nix/nixos-module/default.nix @@ -1,19 +1,21 @@ -{ config, lib, ... }: +{ self, config, lib, ... }: let inherit (config.networking) hostName; inherit (lib) optional; - hostConfig = config.site.hosts.${hostName}; + hostConfig = self.lib.config.site.hosts.${hostName}; in -{ +builtins.trace (lib.generators.toPretty {} self.lib.config) { imports = [ + #{ config = self.lib.config; } ./defaults.nix - ] - ++ optional (hostConfig.role == "server") [ - ./lxc-containers.nix - ] - ++ optional (hostConfig.role == "container") [ - ./container.nix + ../lib/config/options.nix ]; + # ++ optional (hostConfig.role == "server") [ + # #./lxc-containers.nix + # ] + # ++ optional (hostConfig.role == "container") [ + # ./container.nix + # ]; }