about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/make-package-set.nix
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2021-11-20 16:31:02 +0100
committersterni <sternenseemann@systemli.org>2022-01-06 12:21:45 +0100
commitbaaf9459d6105c243239289e1e82e3cdd5ac4809 (patch)
treed5216fceb59132cb2e10dc07bdd51c8db6339cc4 /pkgs/development/haskell-modules/make-package-set.nix
parentf662c8be61bb678797b18ae1874ad992e6102511 (diff)
downloadnixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.tar
nixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.tar.gz
nixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.tar.bz2
nixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.tar.lz
nixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.tar.xz
nixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.tar.zst
nixlib-baaf9459d6105c243239289e1e82e3cdd5ac4809.zip
haskellPackages.callPackage: support returning functions
Overrideable functions are possible by wrapping them as functors in an
attribute set first and appending the overrideScope and override
attributes later.
Diffstat (limited to 'pkgs/development/haskell-modules/make-package-set.nix')
-rw-r--r--pkgs/development/haskell-modules/make-package-set.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix
index 62bcf7dc84c3..982041982503 100644
--- a/pkgs/development/haskell-modules/make-package-set.nix
+++ b/pkgs/development/haskell-modules/make-package-set.nix
@@ -87,8 +87,11 @@ let
       drv = if lib.isFunction fn then fn else import fn;
       auto = builtins.intersectAttrs (lib.functionArgs drv) scope;
 
+      # Converts a returned function to a functor attribute set if necessary
+      ensureAttrs = v: if builtins.isFunction v then { __functor = _: v; } else v;
+
       # this wraps the `drv` function to add a `overrideScope` function to the result.
-      drvScope = allArgs: drv allArgs // {
+      drvScope = allArgs: ensureAttrs (drv allArgs) // {
         overrideScope = f:
           let newScope = mkScope (fix' (extends f scope.__unfix__));
           # note that we have to be careful here: `allArgs` includes the auto-arguments that