1{2 lib,3 fleetLib,4 config,5 nixpkgs,6 ...7}:8with lib;9with fleetLib; let10 hostModule = with types;11 {...} @ hostConfig: let12 hostName = hostConfig.config._module.args.name;13 in {14 options = {15 modules = mkOption {16 type = listOf (mkOptionType {17 name = "submodule";18 inherit (submodule {}) check;19 merge = lib.options.mergeOneOption;20 description = "Nixos modules";21 });22 description = "List of nixos modules";23 default = [];24 };25 system = mkOption {26 type = str;27 description = "Type of system";28 };29 encryptionKey = mkOption {30 type = str;31 description = "Encryption key";32 };33 nixosSystem = mkOption {34 type = unspecified;35 description = "Nixos configuration";36 };37 nixpkgs = mkOption {38 type = unspecified;39 description = "Nixpkgs override";40 default = nixpkgs;41 };42 };43 config = {44 nixosSystem = hostConfig.config.nixpkgs.lib.nixosSystem {45 inherit (hostConfig.config) system modules;46 specialArgs = {47 inherit fleetLib;48 fleet = hostsToAttrs (host: config.hosts.${host}.nixosSystem.config);49 };50 };51 modules = [52 ({...}: {53 networking.hostName = mkFleetGeneratorDefault hostName;54 })55 ];56 };57 };58 overlayType = mkOptionType {59 name = "nixpkgs-overlay";60 description = "nixpkgs overlay";61 check = lib.isFunction;62 merge = lib.mergeOneOption;63 };64in {65 options = with types; {66 hosts = mkOption {67 type = attrsOf (submodule hostModule);68 default = {};69 description = "Configurations of individual hosts";70 };71 globalModules = mkOption {72 type = listOf (mkOptionType {73 name = "submodule";74 inherit (submodule {}) check;75 merge = lib.options.mergeOneOption;76 description = "Nixos modules";77 });78 description = "Modules, which should be added to every system";79 default = [];80 };81 overlays = mkOption {82 default = [];83 type = listOf overlayType;84 };85 };86 config = {87 hosts = hostsToAttrs (host: {88 modules =89 config.globalModules90 ++ [91 ({...}: {92 nixpkgs.overlays = config.overlays;93 })94 ];95 });96 globalModules = import ../../nixos/modules/module-list.nix;97 };98}