From b0c1583a0b606560a4a47322fc849cfc1cfa0090 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 10 Jan 2021 22:30:22 +0100 Subject: [PATCH] doc: stdenv.lib -> lib Part of: https://github.com/NixOS/nixpkgs/issues/108938 Changing the documentation to not refer to stdenv.lib is the first step to make people use it directly. --- doc/languages-frameworks/lua.section.md | 3 +-- doc/languages-frameworks/maven.section.md | 4 ++-- doc/languages-frameworks/ocaml.section.md | 10 +++++----- doc/languages-frameworks/perl.section.md | 8 ++++---- doc/languages-frameworks/rust.section.md | 6 +++--- doc/stdenv/meta.xml | 22 +++++++++++----------- doc/stdenv/platform-notes.xml | 2 +- doc/using/configuration.xml | 4 ++-- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/doc/languages-frameworks/lua.section.md b/doc/languages-frameworks/lua.section.md index 248e5971818b..d81949c75f69 100644 --- a/doc/languages-frameworks/lua.section.md +++ b/doc/languages-frameworks/lua.section.md @@ -181,7 +181,7 @@ luaposix = buildLuarocksPackage { disabled = (luaOlder "5.1") || (luaAtLeast "5.4"); propagatedBuildInputs = [ bit32 lua std_normalize ]; - meta = with stdenv.lib; { + meta = with lib; { homepage = "https://github.com/luaposix/luaposix/"; description = "Lua bindings for POSIX"; maintainers = with maintainers; [ vyp lblasc ]; @@ -243,4 +243,3 @@ Following rules should be respected: * Make sure libraries build for all Lua interpreters. * Commit names of Lua libraries should reflect that they are Lua libraries, so write for example `luaPackages.luafilesystem: 1.11 -> 1.12`. - diff --git a/doc/languages-frameworks/maven.section.md b/doc/languages-frameworks/maven.section.md index 5f3979d69fdd..7a863c500bc3 100644 --- a/doc/languages-frameworks/maven.section.md +++ b/doc/languages-frameworks/maven.section.md @@ -116,7 +116,7 @@ The first step will be to build the Maven project as a fixed-output derivation i > Traditionally the Maven repository is at `~/.m2/repository`. We will override this to be the `$out` directory. ```nix -{ stdenv, maven }: +{ stdenv, lib, maven }: stdenv.mkDerivation { name = "maven-repository"; buildInputs = [ maven ]; @@ -139,7 +139,7 @@ stdenv.mkDerivation { outputHashAlgo = "sha256"; outputHashMode = "recursive"; # replace this with the correct SHA256 - outputHash = stdenv.lib.fakeSha256; + outputHash = lib.fakeSha256; } ``` diff --git a/doc/languages-frameworks/ocaml.section.md b/doc/languages-frameworks/ocaml.section.md index 1c5a5473a05e..fa85a27e84f0 100644 --- a/doc/languages-frameworks/ocaml.section.md +++ b/doc/languages-frameworks/ocaml.section.md @@ -7,7 +7,7 @@ Given that most of the OCaml ecosystem is now built with dune, nixpkgs includes Here is a simple package example. It defines an (optional) attribute `minimumOCamlVersion` that will be used to throw a descriptive evaluation error if building with an older OCaml is attempted. It uses the `fetchFromGitHub` fetcher to get its source. It sets the `doCheck` (optional) attribute to `true` which means that tests will be run with `dune runtest -p angstrom` after the build (`dune build -p angstrom`) is complete. It uses `alcotest` as a build input (because it is needed to run the tests) and `bigstringaf` and `result` as propagated build inputs (thus they will also be available to libraries depending on this library). The library will be installed using the `angstrom.install` file that dune generates. ```nix -{ stdenv +{ lib , fetchFromGitHub , buildDunePackage , alcotest @@ -35,8 +35,8 @@ buildDunePackage rec { meta = { homepage = "https://github.com/inhabitedtype/angstrom"; description = "OCaml parser combinators built for speed and memory efficiency"; - license = stdenv.lib.licenses.bsd3; - maintainers = with stdenv.lib.maintainers; [ sternenseemann ]; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ sternenseemann ]; }; } ``` @@ -44,7 +44,7 @@ buildDunePackage rec { Here is a second example, this time using a source archive generated with `dune-release`. It is a good idea to use this archive when it is available as it will usually contain substituted variables such as a `%%VERSION%%` field. This library does not depend on any other OCaml library and no tests are run after building it. ```nix -{ stdenv +{ lib , fetchurl , buildDunePackage }: @@ -60,7 +60,7 @@ buildDunePackage rec { sha256 = "1msg3vycd3k8qqj61sc23qks541cxpb97vrnrvrhjnqxsqnh6ygq"; }; - meta = with stdenv.lib; { + meta = with lib; { homepage = "https://github.com/flowtype/ocaml-wtf8"; description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates."; license = licenses.mit; diff --git a/doc/languages-frameworks/perl.section.md b/doc/languages-frameworks/perl.section.md index 2b31da84553e..309d8ebcc2b3 100644 --- a/doc/languages-frameworks/perl.section.md +++ b/doc/languages-frameworks/perl.section.md @@ -110,7 +110,7 @@ ClassC3Componentised = buildPerlPackage rec { On Darwin, if a script has too many `-Idir` flags in its first line (its “shebang line”), it will not run. This can be worked around by calling the `shortenPerlShebang` function from the `postInstall` phase: ```nix -{ stdenv, buildPerlPackage, fetchurl, shortenPerlShebang }: +{ stdenv, lib, buildPerlPackage, fetchurl, shortenPerlShebang }: ImageExifTool = buildPerlPackage { pname = "Image-ExifTool"; @@ -121,8 +121,8 @@ ImageExifTool = buildPerlPackage { sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3"; }; - buildInputs = stdenv.lib.optional stdenv.isDarwin shortenPerlShebang; - postInstall = stdenv.lib.optional stdenv.isDarwin '' + buildInputs = lib.optional stdenv.isDarwin shortenPerlShebang; + postInstall = lib.optional stdenv.isDarwin '' shortenPerlShebang $out/bin/exiftool ''; }; @@ -151,7 +151,7 @@ $ nix-generate-from-cpan XML::Simple propagatedBuildInputs = [ XMLNamespaceSupport XMLSAX XMLSAXExpat ]; meta = { description = "An API for simple XML files"; - license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + license = with lib.licenses; [ artistic1 gpl1Plus ]; }; }; ``` diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index 231cbe900e7d..092e84461b81 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -32,7 +32,7 @@ rustPlatform.buildRustPackage rec { cargoSha256 = "03wf9r2csi6jpa7v5sw5lpxkrk4wfzwmzx7k3991q3bdjzcwnnwp"; - meta = with stdenv.lib; { + meta = with lib; { description = "A fast line-oriented regex search tool, similar to ag and ack"; homepage = "https://github.com/BurntSushi/ripgrep"; license = licenses.unlicense; @@ -58,13 +58,13 @@ then be taken from the failed build. A fake hash can be used for `cargoSha256` as follows: ``` - cargoSha256 = stdenv.lib.fakeSha256; + cargoSha256 = lib.fakeSha256; ``` For `cargoHash` you can use: ``` - cargoHash = stdenv.lib.fakeHash; + cargoHash = lib.fakeHash; ``` Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html) diff --git a/doc/stdenv/meta.xml b/doc/stdenv/meta.xml index c9d1b1362193..10802d1af59f 100644 --- a/doc/stdenv/meta.xml +++ b/doc/stdenv/meta.xml @@ -5,7 +5,7 @@ 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: -meta = with stdenv.lib; { +meta = with lib; { description = "A program that produces a familiar, friendly greeting"; longDescription = '' GNU Hello is a program that prints "Hello, world!" when you run it. @@ -155,7 +155,7 @@ hello-2.3 A program that produces a familiar, friendly greeting - Single license referenced by attribute (preferred) stdenv.lib.licenses.gpl3Only. + Single license referenced by attribute (preferred) lib.licenses.gpl3Only. @@ -170,7 +170,7 @@ hello-2.3 A program that produces a familiar, friendly greeting - Multiple licenses referenced by attribute (preferred) with stdenv.lib.licenses; [ asl20 free ofl ]. + Multiple licenses referenced by attribute (preferred) with lib.licenses; [ asl20 free ofl ]. @@ -211,9 +211,9 @@ hello-2.3 A program that produces a familiar, friendly greeting The list of Nix platform types on which the package is supported. Hydra builds packages according to the platform specified. If no platform is specified, the package does not have prebuilt binaries. An example is: -meta.platforms = stdenv.lib.platforms.linux; +meta.platforms = lib.platforms.linux; - Attribute Set stdenv.lib.platforms defines various common lists of platforms types. + Attribute Set lib.platforms defines various common lists of platforms types. @@ -262,7 +262,7 @@ meta.platforms = stdenv.lib.platforms.linux; The list of Nix platform types for which the Hydra instance at hydra.nixos.org will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of meta.platforms. Thus, the only reason to set meta.hydraPlatforms is if you want hydra.nixos.org to build the package on a subset of meta.platforms, or not at all, e.g. -meta.platforms = stdenv.lib.platforms.linux; +meta.platforms = lib.platforms.linux; meta.hydraPlatforms = []; @@ -294,7 +294,7 @@ meta.hydraPlatforms = []; Licenses - The meta.license attribute should preferrably contain a value from stdenv.lib.licenses defined in nixpkgs/lib/licenses.nix, or in-place license description of the same format if the license is unlikely to be useful in another expression. + The meta.license attribute should preferrably contain a value from lib.licenses defined in nixpkgs/lib/licenses.nix, or in-place license description of the same format if the license is unlikely to be useful in another expression. @@ -302,7 +302,7 @@ meta.hydraPlatforms = []; - stdenv.lib.licenses.free, "free" + lib.licenses.free, "free" @@ -312,7 +312,7 @@ meta.hydraPlatforms = []; - stdenv.lib.licenses.unfreeRedistributable, "unfree-redistributable" + lib.licenses.unfreeRedistributable, "unfree-redistributable" @@ -325,7 +325,7 @@ meta.hydraPlatforms = []; - stdenv.lib.licenses.unfree, "unfree" + lib.licenses.unfree, "unfree" @@ -335,7 +335,7 @@ meta.hydraPlatforms = []; - stdenv.lib.licenses.unfreeRedistributableFirmware, "unfree-redistributable-firmware" + lib.licenses.unfreeRedistributableFirmware, "unfree-redistributable-firmware" diff --git a/doc/stdenv/platform-notes.xml b/doc/stdenv/platform-notes.xml index 5a266fdc0eea..cc8efaece129 100644 --- a/doc/stdenv/platform-notes.xml +++ b/doc/stdenv/platform-notes.xml @@ -32,7 +32,7 @@ stdenv.mkDerivation { stdenv.mkDerivation { name = "libfoo-1.2.3"; # ... - makeFlags = stdenv.lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libfoo.dylib"; + makeFlags = lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libfoo.dylib"; } diff --git a/doc/using/configuration.xml b/doc/using/configuration.xml index 336bdf5b2656..1e1df867e08e 100644 --- a/doc/using/configuration.xml +++ b/doc/using/configuration.xml @@ -157,7 +157,7 @@ The following example configuration whitelists the licenses amd and wtfpl: { - whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ]; + whitelistedLicenses = with lib.licenses; [ amd wtfpl ]; } @@ -165,7 +165,7 @@ The following example configuration blacklists the gpl3Only and agpl3Only licenses: { - blacklistedLicenses = with stdenv.lib.licenses; [ agpl3Only gpl3Only ]; + blacklistedLicenses = with lib.licenses; [ agpl3Only gpl3Only ]; }