diff --git a/flake.nix b/flake.nix index a9272ee..1d0f298 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ ); nixosModule = { ... }: { - imports = nixpkgs.lib.filesystem.listFilesRecursive ./nix/nixos-modules; + imports = [ ./nix/nixos-module ]; }; nixosConfigurations.test_vm = diff --git a/nix/nixos-modules/container.nix b/nix/nixos-module/container.nix similarity index 100% rename from nix/nixos-modules/container.nix rename to nix/nixos-module/container.nix diff --git a/nix/nixos-module/default.nix b/nix/nixos-module/default.nix new file mode 100644 index 000000000..4474365 --- /dev/null +++ b/nix/nixos-module/default.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +let + inherit (config.networking) hostName; + inherit (lib) optional; + + startsWith = prefix: s: + builtins.substr 0 (builtins.stringLength prefix) s == prefix; + + isServer = startsWith "server" hostName; +in +{ + imports = [ + ./defaults.nix + ] + ++ optional isServer [ + ./lxc-containers.nix + ] + ++ optional !isServer [ + ./container.nix + ]; +} diff --git a/nix/nixos-modules/defaults.nix b/nix/nixos-module/defaults.nix similarity index 100% rename from nix/nixos-modules/defaults.nix rename to nix/nixos-module/defaults.nix