diff options
author | Robert Hensing <robert@roberthensing.nl> | 2021-12-23 20:54:57 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-05-02 08:49:31 +0200 |
commit | d629ba27d963664282253e6bf32d0f1a38af796a (patch) | |
tree | 00cf628e8fc1ea7ff563b068292f9504dd0f94cf /doc/stdenv/meta.chapter.md | |
parent | 41b3688ba1222b61d19e6f810c9a1867eef69141 (diff) |
Use finalAttrs instead of self for mkDerivation "overlay"
Diffstat (limited to 'doc/stdenv/meta.chapter.md')
-rw-r--r-- | doc/stdenv/meta.chapter.md | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index e57669e261b31..ca8dd1d824fe7 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -176,18 +176,21 @@ The NixOS tests are available as `nixosTests` in parameters of derivations. For NixOS tests run in a VM, so they are slower than regular package tests. For more information see [NixOS module tests](https://nixos.org/manual/nixos/stable/#sec-nixos-tests). Alternatively, you can specify other derivations as tests. You can make use of -the optional parameter (here: `self`) to inject the correct package without -relying on non-local definitions, even in the presence of `overrideAttrs`. This -means `(mypkg.overrideAttrs f).passthru.tests` will be as expected, as long as the +the optional parameter to inject the correct package without +relying on non-local definitions, even in the presence of `overrideAttrs`. +Here that's `finalAttrs.public`, but you could choose a different name if +`finalAttrs` already exists in your scope. + +`(mypkg.overrideAttrs f).passthru.tests` will be as expected, as long as the definition of `tests` does not rely on the original `mypkg` or overrides it in all places. ```nix # my-package/default.nix { stdenv, callPackage }: -stdenv.mkDerivation (self: { +stdenv.mkDerivation (finalAttrs: { # ... - passthru.tests.example = callPackage ./example.nix { my-package = self.public; } + passthru.tests.example = callPackage ./example.nix { my-package = finalAttrs.public; } }) ``` |