2023-03-28 11:38:24 +03:00
|
|
|
{
|
|
|
|
self,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
flake.options.lib = lib.mkOption {
|
|
|
|
type = lib.types.lazyAttrsOf lib.types.raw;
|
|
|
|
};
|
2023-09-06 01:42:04 +03:00
|
|
|
flake.config.lib.importPackages = args @ {
|
|
|
|
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:
|
|
|
|
self.lib.evalModules (forwardedArgs
|
|
|
|
// {
|
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-03-28 11:38:24 +03:00
|
|
|
flake.config.lib.evalModules = args @ {
|
|
|
|
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-08-31 16:03:07 +03:00
|
|
|
self.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-08-31 16:03:07 +03:00
|
|
|
dream2nix.modules.dream2nix = self.modules.dream2nix;
|
2023-09-12 01:01:03 +03:00
|
|
|
dream2nix.overrides = self.overrides;
|
2023-06-29 16:56:40 +03:00
|
|
|
dream2nix.lib.evalModules = self.lib.evalModules;
|
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;
|
|
|
|
}
|