From 0123200dee6bd3f94dbf6fed376b3208dcefe309 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Sat, 24 Jun 2017 12:42:56 +0200 Subject: stdenv: add stawman docs for `makeOverridable` Also fix a typo in docs in haskell-modules. --- lib/customisation.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/customisation.nix b/lib/customisation.nix index 6d6c02340878..98a46ca6c616 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -51,6 +51,24 @@ rec { else { })); + /* `makeOverridable` takes a function from attribute set to attribute set and + injects `override` attibute which can be used to override arguments of + the function. + + nix-repl> x = {a, b}: { result = a + b; } + + nix-repl> y = lib.makeOverridable x { a = 1; b = 2; } + + nix-repl> y + { override = «lambda»; overrideDerivation = «lambda»; result = 3; } + + nix-repl> y.override { a = 10; } + { override = «lambda»; overrideDerivation = «lambda»; result = 12; } + + Please refer to "Nixpkgs Contributors Guide" section + ".overrideDerivation" to learn about `overrideDerivation` and caveats + related to its use. + */ makeOverridable = f: origArgs: let ff = f origArgs; -- cgit 1.4.1