NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

Documentation: use of final: prev: vs self: super: #259237

Open henrik-ch opened 1 year ago

henrik-ch commented 1 year ago

Problem

As mentioned in https://github.com/tazjin/nix-1p at the bottom:

"See the Nix manual sections on overrides and on overlays for more details (note: the convention has moved away from using self in favor of final, and prev instead of super, but the documentation has not been updated to reflect this)."

Proposal

If we generate a local copy of the manual with wget wget -p -k https://nixos.org/manual/nixpkgs/stable/ and count occurences of "self: super:" we get:

$ grep -n "self: super:" index.html
565:self: super:
610:self: super:
630:self: super:
662:self: super:
684:import pkgs.path { overlays = [ (self: super: {
4755:self: super:
4762:  self: super: super.prefer-remote-fetch self super
6107:self: super:
8949:  elixir_1_13_1_overlay = (self: super: {
9610:  dhallOverlay = self: super: {
9614:  overlay = self: super: {
9678:  dhallOverrides = self: super: {
9865:  dhallOverrides = self: super: {
9873:  dhallOverrides = self: super: {
9881:  dhallOverrides = self: super: {
11395:self: super: {
12106:  sbcl' = sbcl.withOverrides (self: super: {
12129:  sbcl' = sbcl.withOverrides (self: super: {
12187:        <code class="literal">packageOverrides</code>: Package overrides config (Default: <code class="literal">(self: super: {})</code>)
13303:self: super: {
13986:    packageOverrides = self: super: {
14232:    packageOverrides = self: super: {
14250:    packageOverrides = self: super: {
14266:  newpkgs = import pkgs.path { overlays = [ (self: super: {
14432:    overrides = self: super: {
14439:self: super: {
14807:      (self: super: {
16083:self: super: { dlib = super.dlib.override { avxSupport = false; }; }
16247:overrides = self: super: rec {
16572:  customMods = self: super: lib.recursiveUpdate super {

on the other hand, we get some but fewer occurences of "final: prev:"

$ grep -n "final: prev:" index.html
8782:    overrides = (final: prev: {
9386:  cudaPackages = cudaPackages_11_5.overrideScope' (final: prev: {
11318:  (final: prev:
11332:  (final: prev:
12241:final: prev:
13105:  packageOverrides = final: prev: {
14456:final: prev: {

The suggestion to fix this is to make a PR to make this consistent across all of the nixpkgs manual.

Checklist

fricklerhandwerk commented 1 year ago

Fixing that would be a great basis for when https://github.com/NixOS/nix.dev/issues/731 lands. Then new users won't be confused by the unexplained variants.