Skip to content

Commit

Permalink
modules: fixup core modules for docs rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
DavHau committed Oct 11, 2023
1 parent cd7dee1 commit d2e9a49
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 74 deletions.
17 changes: 16 additions & 1 deletion modules/dream2nix/buildPythonPackage/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}
16 changes: 0 additions & 16 deletions modules/dream2nix/buildPythonPackage/implementation.nix

This file was deleted.

3 changes: 3 additions & 0 deletions modules/dream2nix/core/docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
'';
};
in {
imports = [
../deps
];
options = {
public.docs = l.mkOption {
type = t.package;
Expand Down
1 change: 1 addition & 0 deletions modules/dream2nix/core/eval-cache/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
in {
imports = [
./interface.nix
../deps
];

config = l.mkMerge [configIfEnabled configIfDisabled];
Expand Down
1 change: 1 addition & 0 deletions modules/dream2nix/core/paths/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
}: {
imports = [
./interface.nix
../deps
];
deps = {nixpkgs, ...}: {
python3 = nixpkgs.python3;
Expand Down
1 change: 1 addition & 0 deletions modules/dream2nix/core/ui/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{config, ...}: {
imports = [
./interface.nix
../public
];

config.public.name = config.name;
Expand Down
9 changes: 0 additions & 9 deletions modules/dream2nix/mkDerivation-sane-defaults/default.nix

This file was deleted.

17 changes: 9 additions & 8 deletions modules/dream2nix/nixpkgs-overrides/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
config,
dream2nix,
lib,
options,
...
Expand Down Expand Up @@ -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"
Expand All @@ -70,6 +72,5 @@ in {
"src"
"outputs"
];
}
];
};
}
1 change: 1 addition & 0 deletions modules/dream2nix/nixpkgs-overrides/interface.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions modules/flake-parts/core-modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
56 changes: 20 additions & 36 deletions modules/flake-parts/website.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit d2e9a49

Please sign in to comment.