summary refs log tree commit diff
path: root/lib/customisation.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-01-31 14:02:19 -0500
committerShea Levy <shea@shealevy.com>2018-01-31 14:02:19 -0500
commit943592f69850fd07dd2422da062b1c1ebc45974d (patch)
tree3376a06cd3ab25a1622c8f320573ab09b55a9470 /lib/customisation.nix
parent0d7a0d7572d35526ddf34b6d011b7b88a8904b36 (diff)
downloadnixlib-943592f69850fd07dd2422da062b1c1ebc45974d.tar
nixlib-943592f69850fd07dd2422da062b1c1ebc45974d.tar.gz
nixlib-943592f69850fd07dd2422da062b1c1ebc45974d.tar.bz2
nixlib-943592f69850fd07dd2422da062b1c1ebc45974d.tar.lz
nixlib-943592f69850fd07dd2422da062b1c1ebc45974d.tar.xz
nixlib-943592f69850fd07dd2422da062b1c1ebc45974d.tar.zst
nixlib-943592f69850fd07dd2422da062b1c1ebc45974d.zip
Add setFunctionArgs lib function.
Among other things, this will allow *2nix tools to output plain data
while still being composable with the traditional
callPackage/.override interfaces.
Diffstat (limited to 'lib/customisation.nix')
-rw-r--r--lib/customisation.nix14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 3988f4e9b690..823395f04d4a 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -1,7 +1,7 @@
 { lib }:
 let
 
-  inherit (builtins) attrNames isFunction;
+  inherit (builtins) attrNames;
 
 in
 
@@ -72,7 +72,7 @@ rec {
   makeOverridable = f: origArgs:
     let
       ff = f origArgs;
-      overrideWith = newArgs: origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs);
+      overrideWith = newArgs: origArgs // (if lib.isFunction newArgs then newArgs origArgs else newArgs);
     in
       if builtins.isAttrs ff then (ff // {
         override = newArgs: makeOverridable f (overrideWith newArgs);
@@ -81,7 +81,7 @@ rec {
         ${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv:
           makeOverridable (args: (f args).overrideAttrs fdrv) origArgs;
       })
-      else if builtins.isFunction ff then {
+      else if lib.isFunction ff then {
         override = newArgs: makeOverridable f (overrideWith newArgs);
         __functor = self: ff;
         overrideDerivation = throw "overrideDerivation not yet supported for functors";
@@ -112,8 +112,8 @@ rec {
   */
   callPackageWith = autoArgs: fn: args:
     let
-      f = if builtins.isFunction fn then fn else import fn;
-      auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
+      f = if lib.isFunction fn then fn else import fn;
+      auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
     in makeOverridable f (auto // args);
 
 
@@ -122,8 +122,8 @@ rec {
      individual attributes. */
   callPackagesWith = autoArgs: fn: args:
     let
-      f = if builtins.isFunction fn then fn else import fn;
-      auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
+      f = if lib.isFunction fn then fn else import fn;
+      auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
       origArgs = auto // args;
       pkgs = f origArgs;
       mkAttrOverridable = name: pkg: makeOverridable (newArgs: (f newArgs).${name}) origArgs;