diff options
author | Anderson Torres <torres.anderson.85@protonmail.com> | 2024-03-06 08:51:54 -0300 |
---|---|---|
committer | Anderson Torres <torres.anderson.85@protonmail.com> | 2024-03-06 11:40:09 -0300 |
commit | e671d3bbbda9b2bec8fa119aa1ff46499118ef17 (patch) | |
tree | de070bfc9392fe6bbb73f786db960279755540a7 /doc/stdenv/meta.chapter.md | |
parent | a2c4602ccd6a9e32dac098abf38bd1fa0fe53dd4 (diff) |
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!
Diffstat (limited to 'doc/stdenv/meta.chapter.md')
-rw-r--r-- | doc/stdenv/meta.chapter.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index c187f0602a1e1..4a3b04b8f6e41 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -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 -meta = with lib; { +meta = { description = "A program that produces a familiar, friendly greeting"; longDescription = '' GNU Hello is a program that prints "Hello, world!" when you run it. It is fully customizable. ''; homepage = "https://www.gnu.org/software/hello/manual/"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ eelco ]; - platforms = platforms.all; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ eelco ]; + platforms = lib.platforms.all; }; ``` |