mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-22 15:04:46 +03:00
modules: fixups for documentation rendering
This commit is contained in:
parent
dc43eeb495
commit
164b965b44
@ -32,7 +32,7 @@
|
||||
in {
|
||||
imports = [
|
||||
../core
|
||||
../package-func/implementation.nix
|
||||
../package-func
|
||||
];
|
||||
|
||||
config.package-func.outputs = cfg.outputs;
|
||||
|
@ -42,7 +42,7 @@
|
||||
in {
|
||||
imports = [
|
||||
../core
|
||||
../package-func/implementation.nix
|
||||
../package-func
|
||||
];
|
||||
|
||||
config.package-func.outputs = cfg.outputs;
|
||||
|
@ -1,6 +1,58 @@
|
||||
# Module to provide an interface for integrating derivation builder functions
|
||||
# like for example, mkDerivation, buildPythonPackage, etc...
|
||||
{
|
||||
config,
|
||||
extendModules,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
|
||||
# outputs needed to assemble a package as proposed in
|
||||
# https://github.com/NixOS/nix/issues/6507
|
||||
outputs = l.unique config.package-func.outputs;
|
||||
|
||||
outputDrvs =
|
||||
l.genAttrs outputs
|
||||
(output: config.package-func.result.${output});
|
||||
|
||||
outputPaths = l.mapAttrs (_: drv: "${drv}") outputDrvs;
|
||||
|
||||
outputDrvsContexts =
|
||||
l.mapAttrsToList (output: path: l.attrNames (l.getContext path)) outputPaths;
|
||||
|
||||
isSingleDrvPackage = (l.length (l.unique outputDrvsContexts)) == 1;
|
||||
|
||||
nonSingleDrvError = ''
|
||||
The package ${config.name} consists of multiple outputs that are built by distinct derivations. It can't be understood as a single derivation.
|
||||
This problem is causes by referencing the package directly. Instead, reference one of its output attributes:
|
||||
- .${l.concatStringsSep "\n - ." outputs}
|
||||
'';
|
||||
|
||||
throwIfMultiDrvOr = returnVal:
|
||||
if isSingleDrvPackage
|
||||
then returnVal
|
||||
else throw nonSingleDrvError;
|
||||
|
||||
public =
|
||||
# out, lib, bin, etc...
|
||||
outputDrvs
|
||||
# outputs, drvPath
|
||||
// {
|
||||
inherit outputs;
|
||||
inherit config extendModules;
|
||||
drvPath = throwIfMultiDrvOr outputDrvs.out.drvPath;
|
||||
outPath = throwIfMultiDrvOr outputDrvs.out.outPath;
|
||||
outputName = throwIfMultiDrvOr outputDrvs.out.outputName;
|
||||
type = "derivation";
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
./interface.nix
|
||||
./implementation.nix
|
||||
../core/public
|
||||
];
|
||||
# the final derivation
|
||||
config.public = public;
|
||||
config.package-func.result =
|
||||
config.package-func.func config.package-func.args;
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
# Module to provide an interface for integrating derivation builder functions
|
||||
# like for example, mkDerivation, buildPythonPackage, etc...
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
extendModules,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
t = l.types;
|
||||
|
||||
# outputs needed to assemble a package as proposed in
|
||||
# https://github.com/NixOS/nix/issues/6507
|
||||
outputs = l.unique config.package-func.outputs;
|
||||
|
||||
outputDrvs =
|
||||
l.genAttrs outputs
|
||||
(output: config.package-func.result.${output});
|
||||
|
||||
outputPaths = l.mapAttrs (_: drv: "${drv}") outputDrvs;
|
||||
|
||||
outputDrvsContexts =
|
||||
l.mapAttrsToList (output: path: l.attrNames (l.getContext path)) outputPaths;
|
||||
|
||||
isSingleDrvPackage = (l.length (l.unique outputDrvsContexts)) == 1;
|
||||
|
||||
nonSingleDrvError = ''
|
||||
The package ${config.name} consists of multiple outputs that are built by distinct derivations. It can't be understood as a single derivation.
|
||||
This problem is causes by referencing the package directly. Instead, reference one of its output attributes:
|
||||
- .${l.concatStringsSep "\n - ." outputs}
|
||||
'';
|
||||
|
||||
throwIfMultiDrvOr = returnVal:
|
||||
if isSingleDrvPackage
|
||||
then returnVal
|
||||
else throw nonSingleDrvError;
|
||||
|
||||
public =
|
||||
# out, lib, bin, etc...
|
||||
outputDrvs
|
||||
# outputs, drvPath
|
||||
// {
|
||||
inherit outputs;
|
||||
inherit config extendModules;
|
||||
drvPath = throwIfMultiDrvOr outputDrvs.out.drvPath;
|
||||
outPath = throwIfMultiDrvOr outputDrvs.out.outPath;
|
||||
outputName = throwIfMultiDrvOr outputDrvs.out.outputName;
|
||||
type = "derivation";
|
||||
};
|
||||
in {
|
||||
# add an option for each output, eg. out, bin, lib, etc...
|
||||
options.public = l.genAttrs outputs (output:
|
||||
l.mkOption {
|
||||
type = t.path;
|
||||
});
|
||||
|
||||
# the final derivation
|
||||
config.public = public;
|
||||
}
|
@ -30,8 +30,17 @@ in {
|
||||
The result of calling the final derivation function.
|
||||
This is not necessarily the same as `final.package`. The function output might not be compatible to the interface of `final.package` and additional logic might be needed to create `final.package`.
|
||||
'';
|
||||
default = config.package-func.func config.package-func.args;
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
# add an option for each output, eg. out, bin, lib, etc...
|
||||
# TODO: these dynamic options cannot be rendered into a manual.
|
||||
# -> removing them for now
|
||||
# -> maybe refactor `public` to be a submodule which is dynamically created
|
||||
# This would not improve the manual but allow for type checking
|
||||
# options.public = l.genAttrs outputs (output:
|
||||
# l.mkOption {
|
||||
# type = t.path;
|
||||
# });
|
||||
};
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
# "nodejs-package-json"
|
||||
# "nodejs-package-lock"
|
||||
# "nodejs-package-lock-v3"
|
||||
# "package-func"
|
||||
"package-func"
|
||||
"php-composer-lock"
|
||||
"php-granular"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user