stdenv.mkDerivation: public -> finalPackage

Changed files
+15 -16
doc
nixos
doc
manual
from_md
release-notes
release-notes
pkgs
applications
misc
hello
stdenv
+2 -2
doc/stdenv/meta.chapter.md
···
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
···
{ 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; };
})
```
+4 -5
doc/stdenv/stdenv.chapter.md
···
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:
···
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';
});
···
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).
+1 -1
doc/using/overrides.chapter.md
···
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`.
+3 -3
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
···
</para>
<para>
Additionally, <literal>passthru</literal> can now reference
-
<literal>finalAttrs.public</literal> containing the final
-
package, including attributes such as the output paths and
-
<literal>overrideAttrs</literal>.
+
<literal>finalAttrs.finalPackage</literal> containing the
+
final package, including attributes such as the output paths
+
and <literal>overrideAttrs</literal>.
</para>
<para>
New language integrations can be simplified by overriding a
+1 -1
nixos/doc/manual/release-notes/rl-2205.section.md
···
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`.
+1 -1
pkgs/applications/misc/hello/default.nix
···
(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";
+3 -3
pkgs/stdenv/generic/make-derivation.nix
···
# 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
···
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.