modules: fixup core modules for docs rendering

This commit is contained in:
DavHau 2023-10-12 00:03:15 +02:00
parent cd7dee14ae
commit d2e9a494d1
11 changed files with 60 additions and 74 deletions

View File

@ -1,6 +1,21 @@
{
config,
dream2nix,
lib,
...
}: let
l = lib // builtins;
in {
imports = [
./implementation.nix
./interface.nix
../mkDerivation
];
config = {
package-func.func = config.deps.python.pkgs.buildPythonPackage;
package-func.args = config.buildPythonPackage;
deps = {nixpkgs, ...}: {
python = l.mkOptionDefault nixpkgs.python3;
};
};
}

View File

@ -1,16 +0,0 @@
{
config,
lib,
...
}: let
l = lib // builtins;
in {
config = {
package-func.func = config.deps.python.pkgs.buildPythonPackage;
package-func.args = config.buildPythonPackage;
deps = {nixpkgs, ...}: {
python = l.mkOptionDefault nixpkgs.python3;
};
};
}

View File

@ -69,6 +69,9 @@
'';
};
in {
imports = [
../deps
];
options = {
public.docs = l.mkOption {
type = t.package;

View File

@ -130,6 +130,7 @@
in {
imports = [
./interface.nix
../deps
];
config = l.mkMerge [configIfEnabled configIfDisabled];

View File

@ -5,6 +5,7 @@
}: {
imports = [
./interface.nix
../deps
];
deps = {nixpkgs, ...}: {
python3 = nixpkgs.python3;

View File

@ -1,6 +1,7 @@
{config, ...}: {
imports = [
./interface.nix
../public
];
config.public.name = config.name;

View File

@ -1,9 +0,0 @@
{
config,
lib,
...
}: {
mkDerivation = {
strictDeps = lib.mkDefault true;
};
}

View File

@ -1,5 +1,6 @@
{
config,
dream2nix,
lib,
options,
...
@ -50,15 +51,16 @@
in {
imports = [
./interface.nix
dream2nix.modules.dream2nix.buildPythonPackage
];
config = l.mkMerge [
(l.mkIf cfg.enable {
mkDerivation = extractedMkDerivation;
buildPythonPackage = extractedBuildPythonPackage;
env = extractedEnv;
})
config =
{
mkDerivation = lib.mkIf cfg.enable extractedMkDerivation;
buildPythonPackage = lib.mkIf cfg.enable extractedBuildPythonPackage;
env = lib.mkIf cfg.enable extractedEnv;
}
// {
nixpkgs-overrides.lib = {inherit extractOverrideAttrs extractPythonAttrs;};
nixpkgs-overrides.exclude = [
"all"
@ -70,6 +72,5 @@ in {
"src"
"outputs"
];
}
];
};
}

View File

@ -22,6 +22,7 @@ in {
type = t.nullOr t.package;
description = "package from which to extract the attributes";
default = config.deps.python.pkgs.${config.name} or null;
defaultText = "config.deps.python.pkgs.\${config.name} or null";
};
lib.extractOverrideAttrs = l.mkOption {

View File

@ -14,20 +14,24 @@
;
inherit
(lib)
mapAttrs'
filterAttrs
mapAttrs'
nameValuePair
removeSuffix
;
mapModules = path:
path = self + "/modules/dream2nix/core";
dirs = filterAttrs (name: _: name != "default.nix") (readDir path);
modules =
mapAttrs'
(fn: _:
nameValuePair
(removeSuffix ".nix" fn)
(path + "/${fn}"))
(filterAttrs (_: type: type == "regular" || type == "directory") (readDir path));
(filterAttrs (_: type: type == "regular" || type == "directory") dirs);
in {
# generates future flake outputs: `modules.<kind>.<module-name>`
config.flake.modules.dream2nix = mapModules (self + "/modules/dream2nix/core");
config.flake.modules.dream2nix = modules;
}

View File

@ -9,44 +9,28 @@
inputs',
pkgs,
...
}: {
}: let
excludes = [
# NOT WORKING
# TODO: fix those
"nixpkgs-overrides"
"core"
"flags"
"ui"
"docs"
"env"
"assertions"
# doesn't need to be rendered
"_template"
];
in {
render.inputs =
lib.flip lib.mapAttrs
(lib.filterAttrs (name: module:
lib.elem name [
# "buildPythonPackage"
# "buildRustPackage"
# "builtins-derivation"
"core"
# "groups"
# "mkDerivation"
# "mkDerivation-sane-defaults"
# "nixpkgs-overrides"
"nodejs-devshell"
"nodejs-granular"
"nodejs-granular-v3"
"nodejs-node-modules"
"nodejs-package-json"
"nodejs-package-lock"
"nodejs-package-lock-v3"
"package-func"
"php-composer-lock"
"php-granular"
"pip"
"rust-cargo-lock"
"WIP-python-pdm"
"WIP-python-pyproject"
"WIP-spago"
"lock"
"mkDerivation"
"public"
# NOT WORKING
# "rust-crane"
# "_template"
]) (self.modules.dream2nix))
(lib.filterAttrs
(name: module:
! (lib.elem name excludes))
(self.modules.dream2nix))
(name: module: {
title = name;
module = self.modules.dream2nix.${name};