Export autoImportArgs to modules

This commit is contained in:
Archit Gupta 2023-08-27 00:01:48 -07:00
parent 9672921de0
commit 838e383c50
2 changed files with 19 additions and 18 deletions

View File

@ -4,8 +4,8 @@
{ config, src, lib, flakelight, ... }@args: { config, src, lib, flakelight, ... }@args:
let let
inherit (lib) isFunction mkOption mkIf mkMerge optionalAttrs; inherit (lib) mkOption mkIf mkMerge optionalAttrs;
inherit (flakelight) autoImport; inherit (flakelight) autoImport autoImportArgs;
inherit (flakelight.types) path; inherit (flakelight.types) path;
in in
{ {
@ -17,28 +17,26 @@ in
config = config =
let let
autoImport' = autoImport config.nixDir; autoImport' = autoImport config.nixDir;
autoImportArgs = n: autoImportArgs' = autoImportArgs config.nixDir args;
let v = autoImport' n; in outputs = autoImportArgs' "outputs";
if isFunction v then v args else v;
outputs = autoImportArgs "outputs";
perSystem = autoImport' "perSystem"; perSystem = autoImport' "perSystem";
withOverlays = autoImport' "withOverlays"; withOverlays = autoImport' "withOverlays";
package = autoImport' "package"; package = autoImport' "package";
packages = autoImportArgs "packages"; packages = autoImportArgs' "packages";
overlays = autoImportArgs "overlays"; overlays = autoImportArgs' "overlays";
devShell = autoImportArgs "devShell"; devShell = autoImportArgs' "devShell";
devShells = autoImportArgs "devShells"; devShells = autoImportArgs' "devShells";
app = autoImport' "app"; app = autoImport' "app";
apps = autoImport' "apps"; apps = autoImport' "apps";
checks = autoImport' "checks"; checks = autoImport' "checks";
nixosModule = autoImport' "nixosModule"; nixosModule = autoImport' "nixosModule";
nixosModules = autoImportArgs "nixosModules"; nixosModules = autoImportArgs' "nixosModules";
nixosConfigurations = autoImportArgs [ "nixosConfigurations" "nixos" ]; nixosConfigurations = autoImportArgs' [ "nixosConfigurations" "nixos" ];
homeModule = autoImport' "homeModule"; homeModule = autoImport' "homeModule";
homeModules = autoImportArgs "homeModules"; homeModules = autoImportArgs' "homeModules";
homeConfigurations = autoImportArgs [ "homeConfigurations" "home" ]; homeConfigurations = autoImportArgs' [ "homeConfigurations" "home" ];
template = autoImportArgs "template"; template = autoImportArgs' "template";
templates = autoImportArgs "templates"; templates = autoImportArgs' "templates";
formatters = autoImport' "formatters"; formatters = autoImport' "formatters";
in in
mkMerge [ mkMerge [

View File

@ -6,7 +6,7 @@ localInputs:
let let
inherit (builtins) isAttrs isPath readDir; inherit (builtins) isAttrs isPath readDir;
inherit (localInputs.nixpkgs.lib) attrNames composeManyExtensions inherit (localInputs.nixpkgs.lib) attrNames composeManyExtensions
filter findFirst genAttrs getValues hasSuffix isFunction isList mapAttrs filter findFirst genAttrs getValues hasSuffix isFunction isList
mapAttrsToList pathExists pipe removePrefix removeSuffix evalModules mapAttrsToList pathExists pipe removePrefix removeSuffix evalModules
mkDefault mkOptionType singleton; mkDefault mkOptionType singleton;
inherit (localInputs.nixpkgs.lib.types) coercedTo functionTo listOf; inherit (localInputs.nixpkgs.lib.types) coercedTo functionTo listOf;
@ -24,7 +24,7 @@ let
}).config.outputs; }).config.outputs;
flakelight = { flakelight = {
inherit mkFlake supportedSystem importDir autoImport; inherit mkFlake supportedSystem autoImport autoImportArgs;
types = { types = {
overlay = mkOptionType { overlay = mkOptionType {
@ -90,6 +90,9 @@ let
then importDir (dir + "/${name}") then importDir (dir + "/${name}")
else null; else null;
autoImportArgs = dir: args: name:
let v = autoImport dir name; in
if isFunction v then v args else v;
in in
{ {
lib = flakelight; lib = flakelight;