Fix args passed to autoloaded files

This commit is contained in:
Archit Gupta 2023-08-27 01:19:40 -07:00
parent 838e383c50
commit 62b7dba619

View File

@ -2,11 +2,16 @@
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com> # Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
{ config, src, lib, flakelight, ... }@args: { config, src, lib, flakelight, inputs, outputs, ... }:
let let
inherit (lib) mkOption mkIf mkMerge optionalAttrs; inherit (lib) mkOption mkIf mkMerge optionalAttrs;
inherit (flakelight) autoImport autoImportArgs; inherit (flakelight) autoImport autoImportArgs;
inherit (flakelight.types) path; inherit (flakelight.types) path;
autoloadArgs = { inherit lib src inputs outputs flakelight; };
autoImport' = autoImport config.nixDir;
autoImportArgs' = autoImportArgs config.nixDir autoloadArgs;
in in
{ {
options.nixDir = mkOption { options.nixDir = mkOption {
@ -16,8 +21,6 @@ in
config = config =
let let
autoImport' = autoImport config.nixDir;
autoImportArgs' = autoImportArgs config.nixDir args;
outputs = autoImportArgs' "outputs"; outputs = autoImportArgs' "outputs";
perSystem = autoImport' "perSystem"; perSystem = autoImport' "perSystem";
withOverlays = autoImport' "withOverlays"; withOverlays = autoImport' "withOverlays";
@ -40,6 +43,8 @@ in
formatters = autoImport' "formatters"; formatters = autoImport' "formatters";
in in
mkMerge [ mkMerge [
{ _module.args = { inherit autoloadArgs; }; }
(mkIf (outputs != null) { inherit outputs; }) (mkIf (outputs != null) { inherit outputs; })
(mkIf (perSystem != null) { inherit perSystem; }) (mkIf (perSystem != null) { inherit perSystem; })
(mkIf (withOverlays != null) { inherit withOverlays; }) (mkIf (withOverlays != null) { inherit withOverlays; })