2023-03-28 11:38:24 +03:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-05 05:51:34 +03:00
|
|
|
dream2nix,
|
2023-03-28 11:38:24 +03:00
|
|
|
...
|
2023-11-05 05:51:34 +03:00
|
|
|
}: rec {
|
|
|
|
importPackages = args @ {
|
2023-09-06 01:42:04 +03:00
|
|
|
projectRoot,
|
|
|
|
projectRootFile,
|
|
|
|
packagesDir,
|
|
|
|
...
|
|
|
|
}: let
|
2023-09-20 22:48:16 +03:00
|
|
|
projectRoot = toString args.projectRoot;
|
|
|
|
packagesDir = toString args.packagesDir;
|
2023-09-06 01:42:04 +03:00
|
|
|
packagesDirPath =
|
2023-09-20 22:48:16 +03:00
|
|
|
if lib.hasPrefix projectRoot packagesDir
|
|
|
|
then packagesDir
|
2023-09-06 01:42:04 +03:00
|
|
|
else projectRoot + "/${packagesDir}";
|
|
|
|
forwardedArgs = builtins.removeAttrs args [
|
|
|
|
"projectRoot"
|
|
|
|
"projectRootFile"
|
|
|
|
"packagesDir"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
lib.mapAttrs
|
|
|
|
(
|
|
|
|
module: type:
|
2023-11-05 05:51:34 +03:00
|
|
|
evalModules (forwardedArgs
|
2023-09-06 01:42:04 +03:00
|
|
|
// {
|
2023-09-18 11:47:31 +03:00
|
|
|
modules =
|
|
|
|
args.modules
|
|
|
|
or []
|
|
|
|
++ [
|
|
|
|
(packagesDirPath + "/${module}")
|
|
|
|
{
|
|
|
|
paths.projectRoot = projectRoot;
|
|
|
|
paths.projectRootFile = projectRootFile;
|
2023-09-20 22:48:16 +03:00
|
|
|
paths.package = packagesDir + "/${module}";
|
2023-09-18 11:47:31 +03:00
|
|
|
}
|
|
|
|
];
|
2023-09-06 01:42:04 +03:00
|
|
|
})
|
|
|
|
)
|
|
|
|
(builtins.readDir packagesDirPath);
|
|
|
|
|
2023-11-05 05:51:34 +03:00
|
|
|
evalModules = args @ {
|
2023-03-28 11:38:24 +03:00
|
|
|
packageSets,
|
|
|
|
modules,
|
2023-09-06 01:42:04 +03:00
|
|
|
# If set, returns the result coming form nixpkgs.lib.evalModules as is,
|
2023-03-28 11:38:24 +03:00
|
|
|
# otherwise it returns the derivation only (.config.public).
|
|
|
|
raw ? false,
|
2023-09-03 04:09:12 +03:00
|
|
|
specialArgs ? {},
|
2023-03-28 11:38:24 +03:00
|
|
|
...
|
|
|
|
}: let
|
2023-09-06 01:42:04 +03:00
|
|
|
forwardedArgs = builtins.removeAttrs args [
|
2023-03-28 11:38:24 +03:00
|
|
|
"packageSets"
|
2023-09-03 04:09:12 +03:00
|
|
|
"raw"
|
2023-03-28 11:38:24 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
evaluated =
|
|
|
|
lib.evalModules
|
|
|
|
(
|
2023-09-06 01:42:04 +03:00
|
|
|
forwardedArgs
|
2023-03-28 11:38:24 +03:00
|
|
|
// {
|
|
|
|
modules =
|
|
|
|
args.modules
|
|
|
|
++ [
|
2023-11-05 05:51:34 +03:00
|
|
|
dream2nix.modules.dream2nix.core
|
2023-03-28 11:38:24 +03:00
|
|
|
];
|
2023-03-30 13:58:07 +03:00
|
|
|
specialArgs =
|
2023-09-03 04:09:12 +03:00
|
|
|
specialArgs
|
2023-03-30 13:58:07 +03:00
|
|
|
// {
|
|
|
|
inherit packageSets;
|
2023-11-05 05:51:34 +03:00
|
|
|
dream2nix.modules.dream2nix = dream2nix.modules.dream2nix;
|
|
|
|
dream2nix.overrides = dream2nix.overrides;
|
|
|
|
dream2nix.lib.evalModules = evalModules;
|
|
|
|
dream2nix.inputs = dream2nix.inputs;
|
2023-03-30 13:58:07 +03:00
|
|
|
};
|
2023-03-28 11:38:24 +03:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
result =
|
|
|
|
if raw
|
|
|
|
then evaluated
|
|
|
|
else evaluated.config.public;
|
|
|
|
in
|
|
|
|
result;
|
|
|
|
}
|