diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index ca8dd1d824fe..c1bb3f8863fc 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -178,7 +178,7 @@ NixOS tests run in a VM, so they are slower than regular package tests. For more Alternatively, you can specify other derivations as tests. You can make use of 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 +Here that's `finalAttrs.finalPackage`, 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 @@ -190,7 +190,7 @@ all places. { stdenv, callPackage }: stdenv.mkDerivation (finalAttrs: { # ... - passthru.tests.example = callPackage ./example.nix { my-package = finalAttrs.public; } + passthru.tests.example = callPackage ./example.nix { my-package = finalAttrs.finalPackage; }; }) ``` diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index fb0bdd5e2d7a..d5d27cbf0863 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -336,8 +336,7 @@ The `rec` keyword works at the syntax level and is unaware of overriding. Instead, the definition references `finalAttrs`, allowing users to change `withFeature` consistently with `overrideAttrs`. -`finalAttrs` also contains the attribute `public`, which represents the final package, -including the output paths, etc. +`finalAttrs` also contains the attribute `finalPackage`, which includes the output paths, etc. Let's look at a more elaborate example to understand the differences between various bindings: @@ -352,11 +351,11 @@ let pkg = packages = []; # `passthru.tests` is a commonly defined attribute. - passthru.tests.simple = f finalAttrs.public; + passthru.tests.simple = f finalAttrs.finalPackage; # An example of an attribute containing a function passthru.appendPackages = packages': - finalAttrs.public.overrideAttrs (newSelf: super: { + finalAttrs.finalPackage.overrideAttrs (newSelf: super: { packages = super.packages ++ packages'; }); @@ -368,7 +367,7 @@ let pkg = in pkg ``` -Unlike the `pkg` binding in the above example, the `finalAttrs` parameter always references the final attributes. For instance `(pkg.overrideAttrs(x)).finalAttrs.public` is identical to `pkg.overrideAttrs(x)`, whereas `(pkg.overrideAttrs(x)).original` is the same as the original `pkg`. +Unlike the `pkg` binding in the above example, the `finalAttrs` parameter always references the final attributes. For instance `(pkg.overrideAttrs(x)).finalAttrs.finalPackage` is identical to `pkg.overrideAttrs(x)`, whereas `(pkg.overrideAttrs(x)).original` is the same as the original `pkg`. See also the section about [`passthru.tests`](#var-meta-tests). diff --git a/doc/using/overrides.chapter.md b/doc/using/overrides.chapter.md index 6e69423fe5f7..a97a39354a9d 100644 --- a/doc/using/overrides.chapter.md +++ b/doc/using/overrides.chapter.md @@ -48,7 +48,7 @@ In the above example, the `separateDebugInfo` attribute is overridden to be true The argument `previousAttrs` is conventionally used to refer to the attr set originally passed to `stdenv.mkDerivation`. -The argument `finalAttrs` refers to the final attributes passed to `mkDerivation`, plus the `public` attribute which is the result of `mkDerivation` — the derivation or package. +The argument `finalAttrs` refers to the final attributes passed to `mkDerivation`, plus the `finalPackage` attribute which is equal to the result of `mkDerivation` or subsequent `overrideAttrs` calls. If only a one-argument function is written, the argument has the meaning of `previousAttrs`. diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index c91fb4d90f09..3f0db0068d0c 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -57,9 +57,9 @@ Additionally, passthru can now reference - finalAttrs.public containing the final - package, including attributes such as the output paths and - overrideAttrs. + finalAttrs.finalPackage containing the + final package, including attributes such as the output paths + and overrideAttrs. New language integrations can be simplified by overriding a diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index 6dec64695d2f..1fba4fbbe2c9 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -23,7 +23,7 @@ In addition to numerous new and upgraded packages, this release has the followin This allows packaging configuration to be overridden in a consistent manner by providing an alternative to `rec {}` syntax. - Additionally, `passthru` can now reference `finalAttrs.public` containing + Additionally, `passthru` can now reference `finalAttrs.finalPackage` containing the final package, including attributes such as the output paths and `overrideAttrs`. diff --git a/pkgs/applications/misc/hello/default.nix b/pkgs/applications/misc/hello/default.nix index 676d10d06ce5..c82de2ae0277 100644 --- a/pkgs/applications/misc/hello/default.nix +++ b/pkgs/applications/misc/hello/default.nix @@ -28,7 +28,7 @@ stdenv.mkDerivation (finalAttrs: { (nixos { environment.noXlibs = true; }).pkgs.hello; }; - passthru.tests.run = callPackage ./test.nix { hello = finalAttrs.public; }; + passthru.tests.run = callPackage ./test.nix { hello = finalAttrs.finalPackage; }; meta = with lib; { description = "A program that produces a familiar, friendly greeting"; diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 3e3a7aa790db..6d9f6a9e3360 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -24,10 +24,10 @@ let # separate lines, because Nix would only show the last line of the comment. # An infinite recursion here can be caused by having the attribute names of expression `e` in `.overrideAttrs(finalAttrs: previousAttrs: e)` depend on `finalAttrs`. Only the attribute values of `e` can depend on `finalAttrs`. - args = rattrs (args // { inherit public; }); + args = rattrs (args // { inherit finalPackage; }); # ^^^^ - public = + finalPackage = mkDerivationSimple (f0: let @@ -51,7 +51,7 @@ let makeDerivationExtensible mkDerivationSimple (self: let super = rattrs self; in super // f self super)) args; - in public; + in finalPackage; # makeDerivationExtensibleConst == makeDerivationExtensible (_: attrs), # but pre-evaluated for a slight improvement in performance.