--- a/lib/flakePart.nix +++ b/lib/flakePart.nix @@ -74,6 +74,7 @@ fleetLib = import ../lib { inherit (bootstrapNixpkgs) lib; }; + _fleetFlakeRootConfig = config; }; }; in --- a/modules/fleetLib.nix +++ b/modules/fleetLib.nix @@ -1,8 +1,4 @@ -{ - lib, - config, - ... -}: { +{lib, ...}: { _module.args.fleetLib = import ../../lib { inherit lib; }; --- a/modules/nixos.nix +++ b/modules/nixos.nix @@ -3,12 +3,14 @@ fleetLib, inputs, config, + _fleetFlakeRootConfig, ... }: let inherit (lib.attrsets) mapAttrs; inherit (lib.options) mkOption; inherit (lib.types) deferredModule; inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.strings) escapeNixIdentifier; inherit (fleetLib.options) mkHostsOption; _file = ./nixos.nix; @@ -28,15 +30,25 @@ Nixos configuration for the current host. ''; type = deferredModule; - apply = module: + apply = module: let + inherit (hostArgs.config) system; + in config.nixpkgs.buildUsing.lib.nixosSystem { - inherit (hostArgs.config) system; + inherit system; modules = [ (module // {key = "attr";}) (config.nixos // {key = "attr";}) ]; specialArgs = { inherit fleetLib inputs; + inputs' = mapAttrs (inputName: input: + builtins.addErrorContext "while retrieving system-dependent attributes for input ${escapeNixIdentifier inputName}" + ( + if input._type or null == "flake" + then _fleetFlakeRootConfig.perInput system input + else "input is not a flake, perhaps flake = false was added to te input declaration?" + )) + inputs; }; }; };