about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-03-15 12:22:16 +0100
committerRobert Hensing <robert@roberthensing.nl>2022-05-02 08:49:33 +0200
commit0e00acafe9dc8bbd9e6b49d4341b6bf49b6defb8 (patch)
treec1b0fbd649b3788e040c4d7bfb1e615979c75be4
parentf066dddaa5cb6aea4429cd9386d4aa6f3963a889 (diff)
stdenv.mkDerivation: public -> finalPackage
-rw-r--r--doc/stdenv/meta.chapter.md4
-rw-r--r--doc/stdenv/stdenv.chapter.md9
-rw-r--r--doc/using/overrides.chapter.md2
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2205.section.xml6
-rw-r--r--nixos/doc/manual/release-notes/rl-2205.section.md2
-rw-r--r--pkgs/applications/misc/hello/default.nix2
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix6
7 files changed, 15 insertions, 16 deletions
diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md
index ca8dd1d824fe7..c1bb3f8863fc4 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 fb0bdd5e2d7a0..d5d27cbf0863e 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 6e69423fe5f70..a97a39354a9d8 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 c91fb4d90f094..3f0db0068d0cd 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 @@
         </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
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md
index 6dec64695d2f6..1fba4fbbe2c92 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 676d10d06ce57..c82de2ae02770 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 3e3a7aa790db2..6d9f6a9e33607 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.