default.nix: doc: add to body (functions fold and composePackage)

M  default.nix
This commit is contained in:
Anton-Latukha 2020-06-03 22:14:10 +03:00
parent 24dc887658
commit b2e724f558
No known key found for this signature in database
GPG Key ID: 3D84C07E91802E41
1 changed files with 5 additions and 0 deletions

View File

@ -139,6 +139,7 @@ let
haskellPackages = pkgs.haskell.packages.${compiler}.override
overrideHaskellPackages;
# Application of functions from this list to the package in code here happens in the reverse order (from the tail). Some options depend on & override others, so if enabling options caused Nix error or not expected result - change the order, and please do not change this order without proper testing.
listOfSetsOfSwitchExtend =
[
{
@ -195,6 +196,7 @@ let
}
];
# Function that applies enabled option to the package, used in the fold.
funcOnSwitchAppliesFunction = set: object:
if set.switch
then set.function object
@ -240,6 +242,9 @@ let
returnShellEnv = false;
};
# One part of Haskell.lib options are argument switches, those are in `inherit`ed list.
# Other part - are function wrappers over pkg. Fold allows to compose those.
# composePackage = foldr (if switch then function) (package) ([{switch,function}]) == (functionN .. (function1 package))
composedPackage = pkgs.lib.foldr (funcOnSwitchAppliesFunction) package listOfSetsOfSwitchExtend;
in composedPackage