difftreelog
feat make inputs' available in nixos config
in: trunk
3 files changed
lib/flakePart.nixdiffbeforeafterboth--- a/lib/flakePart.nix
+++ b/lib/flakePart.nix
@@ -74,6 +74,7 @@
fleetLib = import ../lib {
inherit (bootstrapNixpkgs) lib;
};
+ _fleetFlakeRootConfig = config;
};
};
in
modules/fleetLib.nixdiffbeforeafterboth--- a/modules/fleetLib.nix
+++ b/modules/fleetLib.nix
@@ -1,8 +1,4 @@
-{
- lib,
- config,
- ...
-}: {
+{lib, ...}: {
_module.args.fleetLib = import ../../lib {
inherit lib;
};
modules/nixos.nixdiffbeforeafterboth1{2 lib,3 fleetLib,4 inputs,5 config,6 ...7}: let8 inherit (lib.attrsets) mapAttrs;9 inherit (lib.options) mkOption;10 inherit (lib.types) deferredModule;11 inherit (lib.modules) mkRemovedOptionModule;12 inherit (fleetLib.options) mkHostsOption;1314 _file = ./nixos.nix;15in {16 options = {17 nixos = mkOption {18 description = ''19 Nixos configuration for all hosts.20 '';21 type = deferredModule;22 };23 hosts = mkHostsOption (hostArgs: {24 inherit _file;25 options = {26 nixos = mkOption {27 description = ''28 Nixos configuration for the current host.29 '';30 type = deferredModule;31 apply = module:32 config.nixpkgs.buildUsing.lib.nixosSystem {33 inherit (hostArgs.config) system;34 modules = [35 (module // {key = "attr<host.nixos>";})36 (config.nixos // {key = "attr<fleet.nixos>";})37 ];38 specialArgs = {39 inherit fleetLib inputs;40 };41 };42 };43 };44 config = {45 # imports = [46 # (mkRemovedOptionModule ["nixosModules"] "replaced with hosts.*.nixos.imports.")47 # ];48 nixos = {49 config._module.args = {50 nixosHosts = mapAttrs (_: value: value.nixos.config) config.hosts;51 hosts = config.hosts;52 host = hostArgs.config;53 };54 };55 };56 });57 };58 imports = [59 (mkRemovedOptionModule ["nixosModules"] "replaced with nixos.imports.")60 ];61 config.nixos.imports =62 import ./nixos/module-list.nix;63}1{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}