difftreelog
feat make self' available in nixos modules
in: trunk
1 file changed
modules/nixos.nixdiffbeforeafterboth1{2 lib,3 fleetLib,4 inputs,5 config,6 _fleetFlakeRootConfig,7 ...8}: let9 inherit (lib.attrsets) mapAttrs;10 inherit (lib.options) mkOption;11 inherit (lib.types) deferredModule;12 inherit (lib.modules) mkRemovedOptionModule;13 inherit (lib.strings) escapeNixIdentifier;14 inherit (fleetLib.options) mkHostsOption;1516 _file = ./nixos.nix;17in {18 options = {19 nixos = mkOption {20 description = ''21 Nixos configuration for all hosts.22 '';23 type = deferredModule;24 };25 hosts = mkHostsOption (hostArgs: {26 inherit _file;27 options = {28 nixos = mkOption {29 description = ''30 Nixos configuration for the current host.31 '';32 type = deferredModule;33 apply = module: let34 inherit (hostArgs.config) system;35 in36 config.nixpkgs.buildUsing.lib.nixosSystem {37 inherit system;38 modules = [39 (module // {key = "attr<host.nixos>";})40 (config.nixos // {key = "attr<fleet.nixos>";})41 ];42 specialArgs = {43 inherit fleetLib inputs;44 inputs' = mapAttrs (inputName: input:45 builtins.addErrorContext "while retrieving system-dependent attributes for input ${escapeNixIdentifierinputName}"46 (47 if input._type or null == "flake"48 then _fleetFlakeRootConfig.perInput system input49 else "input is not a flake, perhaps flake = false was added to te input declaration?"50 ))51 inputs;52 };53 };54 };55 };56 config = {57 # imports = [58 # (mkRemovedOptionModule ["nixosModules"] "replaced with hosts.*.nixos.imports.")59 # ];60 nixos = {61 config._module.args = {62 nixosHosts = mapAttrs (_: value: value.nixos.config) config.hosts;63 hosts = config.hosts;64 host = hostArgs.config;65 };66 };67 };68 });69 };70 imports = [71 (mkRemovedOptionModule ["nixosModules"] "replaced with nixos.imports.")72 ];73 config.nixos.imports =74 import ./nixos/module-list.nix;75}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;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 ${escapeNixIdentifierinputName}"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 };58 config = {59 # imports = [60 # (mkRemovedOptionModule ["nixosModules"] "replaced with hosts.*.nixos.imports.")61 # ];62 nixos = {63 config._module.args = {64 nixosHosts = mapAttrs (_: value: value.nixos.config) config.hosts;65 hosts = config.hosts;66 host = hostArgs.config;67 };68 };69 };70 });71 };72 imports = [73 (mkRemovedOptionModule ["nixosModules"] "replaced with nixos.imports.")74 ];75 config.nixos.imports =76 import ./nixos/module-list.nix;77}