git.delta.rocks / jrsonnet / refs/commits / 05eaddea6c83

difftreelog

feat make inputs' available in nixos config

Yaroslav Bolyukin2024-11-10parent: #c05c232.patch.diff
in: trunk

3 files changed

modifiedlib/flakePart.nixdiffbeforeafterboth
--- a/lib/flakePart.nix
+++ b/lib/flakePart.nix
@@ -74,6 +74,7 @@
               fleetLib = import ../lib {
                 inherit (bootstrapNixpkgs) lib;
               };
+              _fleetFlakeRootConfig = config;
             };
           };
         in
modifiedmodules/fleetLib.nixdiffbeforeafterboth
--- a/modules/fleetLib.nix
+++ b/modules/fleetLib.nix
@@ -1,8 +1,4 @@
-{
-  lib,
-  config,
-  ...
-}: {
+{lib, ...}: {
   _module.args.fleetLib = import ../../lib {
     inherit lib;
   };
modifiedmodules/nixos.nixdiffbeforeafterboth
3 fleetLib,3 fleetLib,
4 inputs,4 inputs,
5 config,5 config,
6 _fleetFlakeRootConfig,
6 ...7 ...
7}: let8}: let
8 inherit (lib.attrsets) mapAttrs;9 inherit (lib.attrsets) mapAttrs;
9 inherit (lib.options) mkOption;10 inherit (lib.options) mkOption;
10 inherit (lib.types) deferredModule;11 inherit (lib.types) deferredModule;
11 inherit (lib.modules) mkRemovedOptionModule;12 inherit (lib.modules) mkRemovedOptionModule;
13 inherit (lib.strings) escapeNixIdentifier;
12 inherit (fleetLib.options) mkHostsOption;14 inherit (fleetLib.options) mkHostsOption;
1315
14 _file = ./nixos.nix;16 _file = ./nixos.nix;
28 Nixos configuration for the current host.30 Nixos configuration for the current host.
29 '';31 '';
30 type = deferredModule;32 type = deferredModule;
31 apply = module:33 apply = module: let
34 inherit (hostArgs.config) system;
35 in
32 config.nixpkgs.buildUsing.lib.nixosSystem {36 config.nixpkgs.buildUsing.lib.nixosSystem {
33 inherit (hostArgs.config) system;37 inherit system;
34 modules = [38 modules = [
35 (module // {key = "attr<host.nixos>";})39 (module // {key = "attr<host.nixos>";})
36 (config.nixos // {key = "attr<fleet.nixos>";})40 (config.nixos // {key = "attr<fleet.nixos>";})
37 ];41 ];
38 specialArgs = {42 specialArgs = {
39 inherit fleetLib inputs;43 inherit fleetLib inputs;
44 inputs' = mapAttrs (inputName: input:
45 builtins.addErrorContext "while retrieving system-dependent attributes for input ${escapeNixIdentifier inputName}"
46 (
47 if input._type or null == "flake"
48 then _fleetFlakeRootConfig.perInput system input
49 else "input is not a flake, perhaps flake = false was added to te input declaration?"
50 ))
51 inputs;
40 };52 };
41 };53 };
42 };54 };