diff options
author | gilice <104317939+gilice@users.noreply.github.com> | 2023-04-15 15:24:15 +0200 |
---|---|---|
committer | gilice <104317939+gilice@users.noreply.github.com> | 2023-04-15 16:06:29 +0200 |
commit | 5d20d9ff9fae0aebb43cace7615ce5908b08380c (patch) | |
tree | 7665875e27f1857a2784bbc14074e87770be18d8 /doc/stdenv | |
parent | ab82a89414ddc48f9eda40bcd9bfd600b1546bae (diff) |
doc/stdenv: don't use name in examples, highlight preferring pname
Diffstat (limited to 'doc/stdenv')
-rw-r--r-- | doc/stdenv/stdenv.chapter.md | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index 081d1e778fe8d..8d125d5b2f334 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -16,7 +16,8 @@ stdenv.mkDerivation { } ``` -(`stdenv` needs to be in scope, so if you write this in a separate Nix expression from `pkgs/all-packages.nix`, you need to pass it as a function argument.) Specifying a `name` and a `src` is the absolute minimum Nix requires. For convenience, you can also use `pname` and `version` attributes and `mkDerivation` will automatically set `name` to `"${pname}-${version}"` by default. Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs, as it allows us to reuse the version easily: +(`stdenv` needs to be in scope, so if you write this in a separate Nix expression from `pkgs/all-packages.nix`, you need to pass it as a function argument.) Specifying a `name` and a `src` is the absolute minimum Nix requires. For convenience, you can also use `pname` and `version` attributes and `mkDerivation` will automatically set `name` to `"${pname}-${version}"` by default. +**Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs**, as it allows us to reuse the version easily: ```nix stdenv.mkDerivation rec { @@ -33,7 +34,8 @@ Many packages have dependencies that are not provided in the standard environmen ```nix stdenv.mkDerivation { - name = "libfoo-1.2.3"; + pname = "libfoo"; + version = "1.2.3"; ... buildInputs = [libbar perl ncurses]; } @@ -45,7 +47,8 @@ Often it is necessary to override or modify some aspect of the build. To make th ```nix stdenv.mkDerivation { - name = "fnord-4.5"; + pname = "fnord"; + version = "4.5"; ... buildPhase = '' gcc foo.c -o foo @@ -65,7 +68,8 @@ While the standard environment provides a generic builder, you can still supply ```nix stdenv.mkDerivation { - name = "libfoo-1.2.3"; + pname = "libfoo"; + version = "1.2.3"; ... builder = ./builder.sh; } |