Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules: fixup core modules for docs rendering #735

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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