From b2e724f558586c6ee9a48ec1ccd54d2bc3533913 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Wed, 3 Jun 2020 22:14:10 +0300 Subject: [PATCH] default.nix: doc: add to body (functions fold and composePackage) M default.nix --- default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/default.nix b/default.nix index f7e47d7..3d890fa 100644 --- a/default.nix +++ b/default.nix @@ -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