diff --git a/docs/docgen.nix b/docs/docgen.nix index db07044..38fc43b 100644 --- a/docs/docgen.nix +++ b/docs/docgen.nix @@ -54,6 +54,7 @@ stdenvNoCC.mkDerivation { docs = 0; flake = 1; devShells = 2; + hosts = 3; }; order = orderMap.${lib.head (lib.splitString "/" relPath)}; diff --git a/flake/default.nix b/flake/default.nix index e508b9f..1907dec 100644 --- a/flake/default.nix +++ b/flake/default.nix @@ -14,6 +14,7 @@ inputs.flake-file.flakeModules.default ../devShells ../docs + ../hosts ]; systems = [ "x86_64-linux" ]; diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..cc7b02b --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,51 @@ +# Hosts + +/** + Entry point for machines' configurations. + + Each host forder must has the following structure: + ``` + └── {hostname} + ├── about.nix + ├── configuration.nix + └── hardware.nix + ``` + + `configuration.nix` can be used to override default values, and `hardware.nix` is used to store hardware-related stuff. + + # About file + File which keep some info about host. It can have these fiels (may be extended in future): + ### `name` + used as `networking.hostName` value + ### `users` + sets machine users. Users must have their configuration defined at `users/` +*/ +{ inputs, ... }: +{ + flake.nixosConfigurations = inputs.nixpkgs.lib.mkMerge ( + map + ( + host: + let + cfg = import ./${host}/about.nix; + in + { + ${host} = inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit cfg; + }; + modules = with inputs; [ + ./${host}/configuration.nix + ./${host}/hardware.nix + ]; + }; + } + ) + ( + let + hosts = builtins.readDir ./.; + in + builtins.filter (name: hosts.${name} == "directory") (builtins.attrNames hosts) + ) + ); +}