{ lib, inputs, ... }: let inherit (lib) attrNames listToAttrs filter filterAttrs mapAttrs nameValuePair nixosSystem readDir warn ; cransConfig = import ../config; get_hosts_names = path: attrNames (filterAttrs (name: type: type == "directory") (readDir path)); get_info = path: filter (x: x != null) ( map ( name: let filePath = path + "/${name}/info.nix"; in if builtins.pathExists filePath then (lib.evalModules { modules = [ ../modules/info filePath ]; specialArgs = { crans = cransConfig; }; }).config else warn "${toString filePath} not found" null ) (get_hosts_names path) ); listInfoToAttrs = infos: add: listToAttrs (map (info: nameValuePair info.name (info // add)) infos); in rec { attrsToNixosSystem = path: all_hosts: hosts: baseModules: mapAttrs ( name: info: nixosSystem { specialArgs = inputs // { hosts = all_hosts; crans = cransConfig; inherit info; }; modules = [ (path + "/${name}") ] ++ baseModules; } ) (filterAttrs (name: info: !(info.isDebian or false)) hosts); attrs_vm_info = listInfoToAttrs (get_info ../hosts/vm) { isVm = true; }; attrs_physique_info = listInfoToAttrs (get_info ../hosts/physiques) { isVm = false; }; attrs_all_info = attrs_physique_info // attrs_vm_info; }