git.delta.rocks / jrsonnet / refs/commits / 89d8c5f2ad38

difftreelog

source

modules/fleet/meta.nix2.3 KiBsourcehistory
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      };38      config = {39        nixosSystem = nixpkgs.lib.nixosSystem {40          inherit (hostConfig.config) system modules;41          specialArgs = {42            inherit fleetLib;43            fleet = hostsToAttrs (host: config.hosts.${host}.nixosSystem.config);44          };45        };46        modules = [47          ({...}: {48            networking.hostName = mkFleetDefault hostName;49          })50        ];51      };52    };53  overlayType = mkOptionType {54    name = "nixpkgs-overlay";55    description = "nixpkgs overlay";56    check = lib.isFunction;57    merge = lib.mergeOneOption;58  };59in {60  options = with types; {61    hosts = mkOption {62      type = attrsOf (submodule hostModule);63      default = {};64      description = "Configurations of individual hosts";65    };66    globalModules = mkOption {67      type = listOf (mkOptionType {68        name = "submodule";69        inherit (submodule {}) check;70        merge = lib.options.mergeOneOption;71        description = "Nixos modules";72      });73      description = "Modules, which should be added to every system";74      default = [];75    };76    overlays = mkOption {77      default = [];78      type = listOf overlayType;79    };80  };81  config = {82    hosts = hostsToAttrs (host: {83      modules =84        config.globalModules85        ++ [86          ({...}: {87            nixpkgs.overlays = config.overlays;88          })89        ];90    });91    globalModules = import ../../nixos/modules/module-list.nix;92  };93}