diff --git a/builtinModules/nixDir.nix b/builtinModules/nixDir.nix index 960f6ee..346e2eb 100644 --- a/builtinModules/nixDir.nix +++ b/builtinModules/nixDir.nix @@ -4,8 +4,8 @@ { config, src, lib, flakelight, ... }@args: let - inherit (lib) isFunction mkOption mkIf mkMerge optionalAttrs; - inherit (flakelight) autoImport; + inherit (lib) mkOption mkIf mkMerge optionalAttrs; + inherit (flakelight) autoImport autoImportArgs; inherit (flakelight.types) path; in { @@ -17,28 +17,26 @@ in config = let autoImport' = autoImport config.nixDir; - autoImportArgs = n: - let v = autoImport' n; in - if isFunction v then v args else v; - outputs = autoImportArgs "outputs"; + autoImportArgs' = autoImportArgs config.nixDir args; + outputs = autoImportArgs' "outputs"; perSystem = autoImport' "perSystem"; withOverlays = autoImport' "withOverlays"; package = autoImport' "package"; - packages = autoImportArgs "packages"; - overlays = autoImportArgs "overlays"; - devShell = autoImportArgs "devShell"; - devShells = autoImportArgs "devShells"; + packages = autoImportArgs' "packages"; + overlays = autoImportArgs' "overlays"; + devShell = autoImportArgs' "devShell"; + devShells = autoImportArgs' "devShells"; app = autoImport' "app"; apps = autoImport' "apps"; checks = autoImport' "checks"; nixosModule = autoImport' "nixosModule"; - nixosModules = autoImportArgs "nixosModules"; - nixosConfigurations = autoImportArgs [ "nixosConfigurations" "nixos" ]; + nixosModules = autoImportArgs' "nixosModules"; + nixosConfigurations = autoImportArgs' [ "nixosConfigurations" "nixos" ]; homeModule = autoImport' "homeModule"; - homeModules = autoImportArgs "homeModules"; - homeConfigurations = autoImportArgs [ "homeConfigurations" "home" ]; - template = autoImportArgs "template"; - templates = autoImportArgs "templates"; + homeModules = autoImportArgs' "homeModules"; + homeConfigurations = autoImportArgs' [ "homeConfigurations" "home" ]; + template = autoImportArgs' "template"; + templates = autoImportArgs' "templates"; formatters = autoImport' "formatters"; in mkMerge [ diff --git a/default.nix b/default.nix index 2a3bc49..98728d4 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,7 @@ localInputs: let inherit (builtins) isAttrs isPath readDir; 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 mkDefault mkOptionType singleton; inherit (localInputs.nixpkgs.lib.types) coercedTo functionTo listOf; @@ -24,7 +24,7 @@ let }).config.outputs; flakelight = { - inherit mkFlake supportedSystem importDir autoImport; + inherit mkFlake supportedSystem autoImport autoImportArgs; types = { overlay = mkOptionType { @@ -90,6 +90,9 @@ let then importDir (dir + "/${name}") else null; + autoImportArgs = dir: args: name: + let v = autoImport dir name; in + if isFunction v then v args else v; in { lib = flakelight;