fix: use modules from makeFlakeOutputs, pass dream2nixConfig to modules specialArgs

This commit is contained in:
Yusuf Bera Ertan 2022-09-27 22:55:41 +03:00
parent 74128bba5d
commit fad33143f9
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
6 changed files with 43 additions and 24 deletions

View File

@ -1,10 +1,11 @@
{dlib, ...}: {
discoverers.default = {subsystem, ...}: {
discoverers.dummy = rec {
name = "dummy";
subsystem = "hello";
discover = {tree}: [
(dlib.construct.discoveredProject {
inherit subsystem;
inherit subsystem name;
inherit (tree) relPath;
name = "hello";
translators = ["dummy"];
subsystemInfo = {};
})

View File

@ -50,22 +50,11 @@ in let
inherit framework;
};
evaledModules = lib.evalModules {
modules =
[./modules/top-level.nix]
++ (config.modules or []);
# TODO: remove specialArgs once all functionality is moved to /src/modules
specialArgs = {
inherit
callPackageDream
dlib
;
};
framework = import ./modules/framework.nix {
inherit lib dlib callPackageDream;
dream2nixConfig = config;
};
framework = evaledModules.config;
/*
The nixos module system seems to break pkgs.callPackage.
Therefore we always need to pass all of pkgs with callPackageDream.
@ -648,9 +637,10 @@ in let
makeOutputs = {
source ? throw "pass a 'source' to 'makeOutputs'",
discoveredProjects ?
framework.functions.discoverers.discoverProjects {
l.debug.traceValSeqN 2
(framework.functions.discoverers.discoverProjects {
inherit projects settings source;
},
}),
pname ? null,
projects ? {},
settings ? [],

View File

@ -89,10 +89,16 @@
config = loadConfig (args.config or {});
dlib = import ./lib {inherit lib config;};
framework = import ./modules/framework.nix {
inherit lib dlib;
dream2nixConfig = config;
callPackageDream = func: args: func args;
};
initD2N = initDream2nix config;
dream2nixFor = l.mapAttrs (_: pkgs: initD2N pkgs) allPkgs;
discoveredProjects = dlib.discoverers.discoverProjects {
discoveredProjects = framework.functions.discoverers.discoverProjects {
inherit projects settings;
tree = dlib.prepareSourceTree {inherit source;};
};
@ -147,7 +153,6 @@
allPkgs = makeNixpkgs pkgs systems;
config = loadConfig (args.config or {});
dlib = import ./lib {inherit lib config;};
initD2N = initDream2nix config;
dream2nixFor = l.mapAttrs (_: pkgs: initD2N pkgs) allPkgs;
@ -182,7 +187,7 @@
flakifiedOutputsList;
in
flakeOutputs;
in rec {
in {
inherit init makeFlakeOutputs makeFlakeOutputsForIndexes;
dlib = import ./lib {
inherit lib;

View File

@ -20,7 +20,7 @@ in {
description = "Subsystem of the discoverer.";
};
discover = lib.mkOption {
type = t.functionTo t.attrs;
type = t.functionTo (t.listOf t.attrs);
default = _: {};
};
};

22
src/modules/framework.nix Normal file
View File

@ -0,0 +1,22 @@
{
dream2nixConfig,
callPackageDream,
dlib,
lib,
}: let
evaledModules = lib.evalModules {
modules = [./top-level.nix] ++ (dream2nixConfig.modules or []);
# TODO: remove specialArgs once all functionality is moved to /src/modules
specialArgs = {
inherit
dream2nixConfig
callPackageDream
dlib
;
};
};
framework = evaledModules.config;
in
framework

View File

@ -1,5 +1,6 @@
{
config,
dream2nixConfig,
dlib,
lib,
...
@ -46,7 +47,7 @@
getDreamLockPath = project: rootProject:
dlib.sanitizeRelativePath
"${config.packagesDir}/${rootProject.name}/${project.relPath or ""}/dream-lock.json";
"${dream2nixConfig.packagesDir}/${rootProject.name}/${project.relPath or ""}/dream-lock.json";
applyProjectSettings = projects: settingsList: let
settingsListForProject = project: