1{2 lib,3 fleetLib,4 inputs,5 self,6 config,7 _fleetFlakeRootConfig,8 ...9}: let10 inherit (lib.attrsets) mapAttrs;11 inherit (lib.options) mkOption;12 inherit (lib.types) deferredModule unspecified;13 inherit (lib.modules) mkRemovedOptionModule;14 inherit (lib.strings) escapeNixIdentifier;15 inherit (fleetLib.options) mkHostsOption;1617 _file = ./nixos.nix;18in {19 options = {20 nixos = mkOption {21 description = ''22 Nixos configuration for all hosts.23 '';24 type = deferredModule;25 };26 hosts = mkHostsOption (hostArgs: {27 inherit _file;28 options = {29 nixos = mkOption {30 description = ''31 Nixos configuration for the current host.32 '';33 type = deferredModule;34 apply = module: let35 inherit (hostArgs.config) system;36 in37 config.nixpkgs.buildUsing.lib.nixosSystem {38 inherit system;39 modules = [40 (module // {key = "attr<host.nixos>";})41 (config.nixos // {key = "attr<fleet.nixos>";})42 ];43 specialArgs = {44 inherit fleetLib inputs self;45 inputs' = mapAttrs (inputName: input:46 builtins.addErrorContext "while retrieving system-dependent attributes for input ${escapeNixIdentifier inputName}"47 (48 if input._type or null == "flake"49 then _fleetFlakeRootConfig.perInput system input50 else "input is not a flake, perhaps flake = false was added to te input declaration?"51 ))52 inputs;53 self' = builtins.addErrorContext "while retrieving system-dependent attributes for a flake's own outputs" (_fleetFlakeRootConfig.perInput system self);54 };55 };56 };57 nixos_unchecked = mkOption {58 type = unspecified;59 };60 };61 config = {62 63 64 65 nixos = {66 config._module.args = {67 nixosHosts = mapAttrs (_: value: value.nixos_unchecked.config) config.hosts;68 hosts = config.hosts;69 host = hostArgs.config;70 };71 };72 nixos_unchecked = hostArgs.config.nixos.extendModules {73 modules = [74 {75 _module.check = false;76 }77 ];78 };79 };80 });81 };82 imports = [83 (mkRemovedOptionModule ["nixosModules"] "replaced with nixos.imports.")84 ];85 config.nixos.imports =86 import ./nixos/module-list.nix;87}