mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-22 06:32:21 +03:00
94db134353
This change adds a `pkgs` arguments to the module args. Accessing packages from nixpkgs becomes easier as the user is not forced to go through `config.deps` anymore. `config.deps` can still be used to override packages from `pkgs`.
87 lines
2.0 KiB
Nix
87 lines
2.0 KiB
Nix
{
|
|
lib,
|
|
dream2nix,
|
|
...
|
|
}: rec {
|
|
importPackages = args @ {
|
|
projectRoot,
|
|
projectRootFile,
|
|
packagesDir,
|
|
...
|
|
}: let
|
|
projectRoot = toString args.projectRoot;
|
|
packagesDir = toString args.packagesDir;
|
|
packagesDirPath =
|
|
if lib.hasPrefix projectRoot packagesDir
|
|
then packagesDir
|
|
else projectRoot + "/${packagesDir}";
|
|
forwardedArgs = builtins.removeAttrs args [
|
|
"projectRoot"
|
|
"projectRootFile"
|
|
"packagesDir"
|
|
];
|
|
in
|
|
lib.mapAttrs
|
|
(
|
|
module: type:
|
|
evalModules (forwardedArgs
|
|
// {
|
|
modules =
|
|
args.modules
|
|
or []
|
|
++ [
|
|
(packagesDirPath + "/${module}")
|
|
{
|
|
paths.projectRoot = projectRoot;
|
|
paths.projectRootFile = projectRootFile;
|
|
paths.package = packagesDir + "/${module}";
|
|
}
|
|
];
|
|
})
|
|
)
|
|
(builtins.readDir packagesDirPath);
|
|
|
|
evalModules = args @ {
|
|
packageSets,
|
|
modules,
|
|
# If set, returns the result coming form nixpkgs.lib.evalModules as is,
|
|
# otherwise it returns the derivation only (.config.public).
|
|
raw ? false,
|
|
specialArgs ? {},
|
|
...
|
|
}: let
|
|
forwardedArgs = builtins.removeAttrs args [
|
|
"packageSets"
|
|
"raw"
|
|
];
|
|
|
|
evaluated =
|
|
lib.evalModules
|
|
(
|
|
forwardedArgs
|
|
// {
|
|
modules =
|
|
args.modules
|
|
++ [
|
|
dream2nix.modules.dream2nix.core
|
|
];
|
|
specialArgs =
|
|
specialArgs
|
|
// {inherit packageSets;}
|
|
// {
|
|
dream2nix.modules.dream2nix = dream2nix.modules.dream2nix;
|
|
dream2nix.overrides = dream2nix.overrides;
|
|
dream2nix.lib.evalModules = evalModules;
|
|
dream2nix.inputs = dream2nix.inputs;
|
|
};
|
|
}
|
|
);
|
|
|
|
result =
|
|
if raw
|
|
then evaluated
|
|
else evaluated.config.public;
|
|
in
|
|
result;
|
|
}
|