1
1
forked from extern/flakelight

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:
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 [

View File

@ -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;