From 943592f69850fd07dd2422da062b1c1ebc45974d Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 31 Jan 2018 14:02:19 -0500 Subject: 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. --- lib/customisation.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/customisation.nix') 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; -- cgit 1.4.1