Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(back): #1101 faster init #1113

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/evaluator/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,19 @@
};
configAsJson = toFileJson "config.json" config.config;
outputs = let
# Trivial
makesDirsNoRoot = lib.remove "/" config.extendingMakesDirs;
makesDirsToReplace = makesDirsNoRoot ++ ["/main.nix"];
emptyList = builtins.map (_: "") makesDirsToReplace;

# Load an attr set distributed across many files and directories
attrs = let
pathInConfig = dir:
builtins.any
(makesDir: lib.hasInfix makesDir dir)
config.extendingMakesDirs;
pathExists = dir: builtins.pathExists (projectSrc + dir);
attrName = dir: let
makesDirsNoRoot = lib.remove "/" config.extendingMakesDirs;
from = makesDirsNoRoot ++ ["/main.nix"];
to = builtins.genList (_: "") ((builtins.length makesDirsNoRoot) + 1);
replaced = builtins.replaceStrings from to dir;
replaced = builtins.replaceStrings makesDirsToReplace emptyList dir;
in
if replaced != ""
then replaced
Expand All @@ -117,7 +118,7 @@
(
dir:
attrsOptional
(pathInConfig dir && pathExists dir)
(pathInConfig dir)
{"${attrName dir}" = import (projectSrc + dir) args;}
)
(fromJson attrPaths).attrs
Expand Down