diff --git a/modules/dream2nix/derivation-common/options.nix b/modules/dream2nix/builtins-derivation/derivation-common/options.nix similarity index 100% rename from modules/dream2nix/derivation-common/options.nix rename to modules/dream2nix/builtins-derivation/derivation-common/options.nix diff --git a/modules/dream2nix/builtins-derivation/interface.nix b/modules/dream2nix/builtins-derivation/interface.nix index 1156c2ed28..4e42bb555e 100644 --- a/modules/dream2nix/builtins-derivation/interface.nix +++ b/modules/dream2nix/builtins-derivation/interface.nix @@ -6,7 +6,7 @@ l = lib // builtins; t = l.types; - common-options = import ../derivation-common/options.nix {inherit lib;}; + common-options = import ./derivation-common/options.nix {inherit lib;}; builtin-derivation-options = { # basic arguments diff --git a/modules/dream2nix/core/lock/default.nix b/modules/dream2nix/core/lock/default.nix index 4d820a4285..fe0da9d935 100644 --- a/modules/dream2nix/core/lock/default.nix +++ b/modules/dream2nix/core/lock/default.nix @@ -191,6 +191,8 @@ in { imports = [ ./interface.nix + ../assertions.nix + ../deps ]; config = { diff --git a/modules/dream2nix/mkDerivation/implementation.nix b/modules/dream2nix/mkDerivation/implementation.nix index 41e89b1918..fdd31d7577 100644 --- a/modules/dream2nix/mkDerivation/implementation.nix +++ b/modules/dream2nix/mkDerivation/implementation.nix @@ -60,4 +60,8 @@ in { inherit (config.public) version; pname = config.name; }; + + config.deps = {nixpkgs, ...}: { + stdenv = lib.mkOverride 1050 nixpkgs.stdenv; + }; } diff --git a/modules/dream2nix/mkDerivation/interface.nix b/modules/dream2nix/mkDerivation/interface.nix index 744666909b..aebab952d7 100644 --- a/modules/dream2nix/mkDerivation/interface.nix +++ b/modules/dream2nix/mkDerivation/interface.nix @@ -8,7 +8,7 @@ l = lib // builtins; t = l.types; - common-options = import ../derivation-common/options.nix {inherit lib;}; + common-options = import ../builtins-derivation/derivation-common/options.nix {inherit lib;}; derivationType = t.oneOf [t.str t.path t.package]; diff --git a/modules/flake-parts/render/default.nix b/modules/flake-parts/render/default.nix index 500549f3cd..107b6e2428 100644 --- a/modules/flake-parts/render/default.nix +++ b/modules/flake-parts/render/default.nix @@ -71,13 +71,20 @@ in { }; eval = evalWith { - modules = concatLists (mapAttrsToList (name: inputCfg: inputCfg.getModules inputCfg.flake) cfg.inputs); + modules = concatLists (mapAttrsToList (name: inputCfg: [inputCfg.module]) cfg.inputs); }; evalWith = {modules}: lib.evalModules { - modules = modules; - specialArgs.dream2nix.modules = self.modules; - specialArgs.packageSets = {}; + modules = + modules + ++ [ + # { + # name = "dummy-name"; + # version = "dummy-version"; + # } + ]; + specialArgs.dream2nix = self; + specialArgs.packageSets.nixpkgs = pkgs; }; # inputs.flake-parts.lib.evalFlakeModule # { @@ -123,23 +130,21 @@ in { in [ { url = baseUrl + subpath; - name = sourceName + subpath; + name = "dream2nix" + subpath; } ] else [] ) opt.declarations; in - # if - # declarations - # == [] - # || ( - # # sourceName != "flake-parts" && coreOptDecls ? ${lib.showOption opt.loc} - # sourceName != "flake-parts" - # ) - # then opt // {visible = false;} - # else opt // {inherit declarations;}; - opt // {inherit declarations;}; + if + declarations + == [] + || ( + (lib.head opt.loc) != sourceName + ) + then opt // {visible = false;} + else opt // {inherit declarations;}; inputModule = { config, @@ -147,12 +152,11 @@ in { ... }: { options = { - flake = mkOption { + module = mkOption { type = types.raw; description = '' - A flake. + A Module. ''; - default = inputs.${name}; }; sourcePath = mkOption { @@ -160,7 +164,6 @@ in { description = '' Source path in which the modules are contained. ''; - default = config.flake.outPath; }; title = mkOption { @@ -224,29 +227,13 @@ in { default = '' ## Installation - ${ - if config.installationDeclareInput - then '' - To use these options, add to your flake inputs: - - ```nix - ${config.sourceName}.url = "${config.flakeRef}"; - ``` - - and inside the `mkFlake`: - '' - else '' - To use these options, add inside the `mkFlake`: - '' - } + To import this module into your dream2nix package: ```nix imports = [ - inputs.${config.sourceName}.${lib.concatMapStringsSep "." lib.strings.escapeNixIdentifier config.attributePath} + ${lib.concatMapStringsSep "." lib.strings.escapeNixIdentifier config.attributePath} ]; ``` - - Run `nix flake lock` and you're set. ''; }; @@ -265,19 +252,6 @@ in { ''; }; - getModules = mkOption { - type = types.functionTo (types.listOf types.raw); - description = '' - Get the modules to render. - ''; - default = flake: [ - ( - builtins.addErrorContext "while getting modules for input '${name}'" - (lib.getAttrFromPath config.attributePath flake) - ) - ]; - }; - attributePath = mkOption { type = types.listOf types.str; description = '' @@ -325,7 +299,7 @@ in { if config.separateEval then (evalWith { - modules = config.getModules config.flake; + modules = [config.module]; }) .options else opts; @@ -334,7 +308,7 @@ in { inherit (config) sourceName baseUrl sourcePath; # inherit coreOptDecls; }; - warningsAreErrors = true; # not sure if feasible long term + warningsAreErrors = false; # not sure if feasible long term markdownByDefault = true; }; rendered = @@ -375,6 +349,20 @@ in { }) cfg.inputs // { + # generate markdown file like: + # Summary + # - [Reference Documentation]() + # - [core (built in)](./options/core.md) + generated-summary-md = pkgs.writeText "SUMMARY.md" '' + # Summary + - [Reference Documentation]() + ${ + lib.concatStringsSep "\n" + (lib.mapAttrsToList + (name: inputCfg: " - [${inputCfg.sourceName}](./options/${name}.md)") + cfg.inputs) + } + ''; generated-docs = pkgs.runCommand "generated-docs" { diff --git a/modules/flake-parts/site/default.nix b/modules/flake-parts/site/default.nix index 2eae8ee83c..66f32ea2fa 100644 --- a/modules/flake-parts/site/default.nix +++ b/modules/flake-parts/site/default.nix @@ -26,7 +26,7 @@ pkgs.runCommand "linkcheck" { nativeBuildInputs = [pkgs.linkchecker pkgs.python3]; - site = config.packages.default; + site = config.packages.website; } '' # https://linkchecker.github.io/linkchecker/man/linkcheckerrc.html cat >>$TMPDIR/linkcheckrc <to the options' \ + # TODO: point to something else than public.html + echo 'to the options' \ >$out/options.html runHook postBuild diff --git a/modules/flake-parts/website.nix b/modules/flake-parts/website.nix index 9b50aca5be..46610eed00 100644 --- a/modules/flake-parts/website.nix +++ b/modules/flake-parts/website.nix @@ -10,15 +10,54 @@ pkgs, ... }: { - render.inputs = { - core = { - title = "core"; - flake.module = self.modules.dream2nix.core; - flake.outPath = self; - attributePath = ["module"]; + 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" + # "pip-hotfixes" + # "rust-cargo-lock" + # "rust-crane" + # "_template" + # "WIP-python-pdm" + # "WIP-python-pyproject" + # "WIP-spago" + + # "lock" + "mkDerivation" + "public" + ]) (self.modules.dream2nix)) + (name: module: { + title = name; + module = self.modules.dream2nix.${name}; + sourcePath = self; + attributePath = [ + "dream2nix" + "modules" + "dream2nix" + (lib.strings.escapeNixIdentifier name) + ]; intro = "intro"; baseUrl = "https://github.com/nix-community/dream2nix/blob/master"; - }; - }; + separateEval = true; + }); }; }