Nix docs: remove with lib; from example code

Following [Best Practices](https://nix.dev/guides/best-practices#with-scopes),
`with` is a problematic language construction and should be avoided.

Usually it is employed like a "factorization": `[ X.A X.B X.C X.D ]` is written
`with X; [ A B C D ]`.

However, as shown in the link above, the syntatical rules of `with` are not so
intuitive, and this "distributive rule" is very selective, in the sense that
`with X; [ A B C D ]` is not equivalent to `[ X.A X.B X.C X.D ]`.

However, this factorization is still useful to "squeeze" some code, especially
in lists like `meta.maintainers`.

On the other hand, it becomes less justifiable in bigger scopes. This is
especially true in cases like `with lib;` in the top of expression and in sets
like `meta = with lib; { . . . }`.

That being said, this patch removes most of example code in the current
documentation.

The exceptions are, for now
- doc/functions/generators.section.md
- doc/languages-frameworks/coq.section.md

because, well, they are way more complicated, and I couldn't parse them
mentally - yet another reason why `with` should be avoided!
This commit is contained in:
Anderson Torres 2024-03-06 08:51:54 -03:00
parent a2c4602ccd
commit e671d3bbbd
11 changed files with 52 additions and 52 deletions

View file

@ -210,11 +210,11 @@ buildDotnetGlobalTool {
nugetSha256 = "sha256-ZG2HFyKYhVNVYd2kRlkbAjZJq88OADe3yjxmLuxXDUo="; nugetSha256 = "sha256-ZG2HFyKYhVNVYd2kRlkbAjZJq88OADe3yjxmLuxXDUo=";
meta = with lib; { meta = {
homepage = "https://cmd.petabridge.com/index.html"; homepage = "https://cmd.petabridge.com/index.html";
changelog = "https://cmd.petabridge.com/articles/RELEASE_NOTES.html"; changelog = "https://cmd.petabridge.com/articles/RELEASE_NOTES.html";
license = licenses.unfree; license = lib.licenses.unfree;
platforms = platforms.linux; platforms = lib.platforms.linux;
}; };
} }
``` ```

View file

@ -51,11 +51,11 @@ pet = buildGoModule rec {
vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA="; vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA=";
meta = with lib; { meta = {
description = "Simple command-line snippet manager, written in Go"; description = "Simple command-line snippet manager, written in Go";
homepage = "https://github.com/knqyf263/pet"; homepage = "https://github.com/knqyf263/pet";
license = licenses.mit; license = lib.licenses.mit;
maintainers = with maintainers; [ kalbasit ]; maintainers = with lib.maintainers; [ kalbasit ];
}; };
} }
``` ```

View file

@ -93,11 +93,11 @@ build-idris-package {
hash = "sha256-h28F9EEPuvab6zrfeE+0k1XGQJGwINnsJEG8yjWIl7w="; hash = "sha256-h28F9EEPuvab6zrfeE+0k1XGQJGwINnsJEG8yjWIl7w=";
}; };
meta = with lib; { meta = {
description = "Idris YAML lib"; description = "Idris YAML lib";
homepage = "https://github.com/Heather/Idris.Yaml"; homepage = "https://github.com/Heather/Idris.Yaml";
license = licenses.mit; license = lib.licenses.mit;
maintainers = [ maintainers.brainrape ]; maintainers = [ lib.maintainers.brainrape ];
}; };
} }
``` ```

View file

@ -184,11 +184,11 @@ buildNpmPackage rec {
NODE_OPTIONS = "--openssl-legacy-provider"; NODE_OPTIONS = "--openssl-legacy-provider";
meta = with lib; { meta = {
description = "A modern web UI for various torrent clients with a Node.js backend and React frontend"; description = "A modern web UI for various torrent clients with a Node.js backend and React frontend";
homepage = "https://flood.js.org"; homepage = "https://flood.js.org";
license = licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = with maintainers; [ winter ]; maintainers = with lib.maintainers; [ winter ];
}; };
} }
``` ```

View file

@ -193,10 +193,10 @@ luaposix = buildLuarocksPackage {
disabled = (luaOlder "5.1") || (luaAtLeast "5.4"); disabled = (luaOlder "5.1") || (luaAtLeast "5.4");
propagatedBuildInputs = [ bit32 lua std_normalize ]; propagatedBuildInputs = [ bit32 lua std_normalize ];
meta = with lib; { meta = {
homepage = "https://github.com/luaposix/luaposix/"; homepage = "https://github.com/luaposix/luaposix/";
description = "Lua bindings for POSIX"; description = "Lua bindings for POSIX";
maintainers = with maintainers; [ vyp lblasc ]; maintainers = with lib.maintainers; [ vyp lblasc ];
license.fullName = "MIT/X11"; license.fullName = "MIT/X11";
}; };
}; };

View file

@ -34,11 +34,11 @@ maven.buildMavenPackage rec {
--add-flags "-jar $out/share/jd-cli/jd-cli.jar" --add-flags "-jar $out/share/jd-cli/jd-cli.jar"
''; '';
meta = with lib; { meta = {
description = "Simple command line wrapper around JD Core Java Decompiler project"; description = "Simple command line wrapper around JD Core Java Decompiler project";
homepage = "https://github.com/intoolswetrust/jd-cli"; homepage = "https://github.com/intoolswetrust/jd-cli";
license = licenses.gpl3Plus; license = lib.licenses.gpl3Plus;
maintainers = with maintainers; [ majiir ]; maintainers = with lib.maintainers; [ majiir ];
}; };
}: }:
``` ```

View file

@ -110,11 +110,11 @@ buildDunePackage rec {
hash = "sha256-d5/3KUBAWRj8tntr4RkJ74KWW7wvn/B/m1nx0npnzyc="; hash = "sha256-d5/3KUBAWRj8tntr4RkJ74KWW7wvn/B/m1nx0npnzyc=";
}; };
meta = with lib; { meta = {
homepage = "https://github.com/flowtype/ocaml-wtf8"; homepage = "https://github.com/flowtype/ocaml-wtf8";
description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates."; description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
license = licenses.mit; license = lib.licenses.mit;
maintainers = [ maintainers.eqyiel ]; maintainers = [ lib.maintainers.eqyiel ];
}; };
} }
``` ```

View file

@ -130,12 +130,12 @@ buildPythonPackage rec {
hypothesis hypothesis
]; ];
meta = with lib; { meta = {
changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}"; changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
description = "Framework for writing tests"; description = "Framework for writing tests";
homepage = "https://github.com/pytest-dev/pytest"; homepage = "https://github.com/pytest-dev/pytest";
license = licenses.mit; license = lib.licenses.mit;
maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ]; maintainers = with lib.maintainers; [ domenkozar lovek323 madjar lsix ];
}; };
} }
``` ```
@ -312,7 +312,7 @@ python3Packages.buildPythonApplication rec {
python-daemon python-daemon
]; ];
meta = with lib; { meta = {
# ... # ...
}; };
} }
@ -899,12 +899,12 @@ buildPythonPackage rec {
"toolz.dicttoolz" "toolz.dicttoolz"
]; ];
meta = with lib; { meta = {
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}"; changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
homepage = "https://github.com/pytoolz/toolz"; homepage = "https://github.com/pytoolz/toolz";
description = "List processing tools and functional utilities"; description = "List processing tools and functional utilities";
license = licenses.bsd3; license = lib.licenses.bsd3;
maintainers = with maintainers; [ fridh ]; maintainers = with lib.maintainers; [ fridh ];
}; };
} }
``` ```
@ -1034,12 +1034,12 @@ buildPythonPackage rec {
pytest pytest
]; ];
meta = with lib; { meta = {
changelog = "https://github.com/blaze/datashape/releases/tag/${version}"; changelog = "https://github.com/blaze/datashape/releases/tag/${version}";
homepage = "https://github.com/ContinuumIO/datashape"; homepage = "https://github.com/ContinuumIO/datashape";
description = "A data description language"; description = "A data description language";
license = licenses.bsd2; license = lib.licenses.bsd2;
maintainers = with maintainers; [ fridh ]; maintainers = with lib.maintainers; [ fridh ];
}; };
} }
``` ```
@ -1084,12 +1084,12 @@ buildPythonPackage rec {
libxslt libxslt
]; ];
meta = with lib; { meta = {
changelog = "https://github.com/lxml/lxml/releases/tag/lxml-${version}"; changelog = "https://github.com/lxml/lxml/releases/tag/lxml-${version}";
description = "Pythonic binding for the libxml2 and libxslt libraries"; description = "Pythonic binding for the libxml2 and libxslt libraries";
homepage = "https://lxml.de"; homepage = "https://lxml.de";
license = licenses.bsd3; license = lib.licenses.bsd3;
maintainers = with maintainers; [ sjourdois ]; maintainers = with lib.maintainers; [ sjourdois ];
}; };
} }
``` ```
@ -1155,12 +1155,12 @@ buildPythonPackage rec {
# Tests cannot import pyfftw. pyfftw works fine though. # Tests cannot import pyfftw. pyfftw works fine though.
doCheck = false; doCheck = false;
meta = with lib; { meta = {
changelog = "https://github.com/pyFFTW/pyFFTW/releases/tag/v${version}"; changelog = "https://github.com/pyFFTW/pyFFTW/releases/tag/v${version}";
description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms"; description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms";
homepage = "http://hgomersall.github.com/pyFFTW"; homepage = "http://hgomersall.github.com/pyFFTW";
license = with licenses; [ bsd2 bsd3 ]; license = with lib.licenses; [ bsd2 bsd3 ];
maintainers = with maintainers; [ fridh ]; maintainers = with lib.maintainers; [ fridh ];
}; };
} }
``` ```
@ -1530,12 +1530,12 @@ buildPythonPackage rec {
wheel wheel
]; ];
meta = with lib; { meta = {
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}"; changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
homepage = "https://github.com/pytoolz/toolz/"; homepage = "https://github.com/pytoolz/toolz/";
description = "List processing tools and functional utilities"; description = "List processing tools and functional utilities";
license = licenses.bsd3; license = lib.licenses.bsd3;
maintainers = with maintainers; [ fridh ]; maintainers = with lib.maintainers; [ fridh ];
}; };
} }
``` ```

View file

@ -35,10 +35,10 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts="; cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts=";
meta = with lib; { meta = {
description = "A fast line-oriented regex search tool, similar to ag and ack"; description = "A fast line-oriented regex search tool, similar to ag and ack";
homepage = "https://github.com/BurntSushi/ripgrep"; homepage = "https://github.com/BurntSushi/ripgrep";
license = licenses.unlicense; license = lib.licenses.unlicense;
maintainers = []; maintainers = [];
}; };
} }
@ -923,11 +923,11 @@ rustPlatform.buildRustPackage rec {
doCheck = false; doCheck = false;
meta = with lib; { meta = {
description = "A fast line-oriented regex search tool, similar to ag and ack"; description = "A fast line-oriented regex search tool, similar to ag and ack";
homepage = "https://github.com/BurntSushi/ripgrep"; homepage = "https://github.com/BurntSushi/ripgrep";
license = with licenses; [ mit unlicense ]; license = with lib.licenses; [ mit unlicense ];
maintainers = with maintainers; []; maintainers = with lib.maintainers; [];
}; };
} }
``` ```

View file

@ -181,11 +181,11 @@ let
runHook postInstall runHook postInstall
''; '';
meta = with lib; { meta = {
description = "A LaTeX2e class for overhead transparencies"; description = "A LaTeX2e class for overhead transparencies";
license = licenses.unfreeRedistributable; license = lib.licenses.unfreeRedistributable;
maintainers = with maintainers; [ veprbl ]; maintainers = with lib.maintainers; [ veprbl ];
platforms = platforms.all; platforms = lib.platforms.all;
}; };
}; };

View file

@ -3,16 +3,16 @@
Nix packages can declare *meta-attributes* that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a `meta` declaration like this: Nix packages can declare *meta-attributes* that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a `meta` declaration like this:
```nix ```nix
meta = with lib; { meta = {
description = "A program that produces a familiar, friendly greeting"; description = "A program that produces a familiar, friendly greeting";
longDescription = '' longDescription = ''
GNU Hello is a program that prints "Hello, world!" when you run it. GNU Hello is a program that prints "Hello, world!" when you run it.
It is fully customizable. It is fully customizable.
''; '';
homepage = "https://www.gnu.org/software/hello/manual/"; homepage = "https://www.gnu.org/software/hello/manual/";
license = licenses.gpl3Plus; license = lib.licenses.gpl3Plus;
maintainers = with maintainers; [ eelco ]; maintainers = with lib.maintainers; [ eelco ];
platforms = platforms.all; platforms = lib.platforms.all;
}; };
``` ```