Skip to content

Commit

Permalink
Merge pull request #226280 from gilice/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
fricklerhandwerk committed Apr 15, 2023
2 parents 7baae9c + 5d20d9f commit 21b6b86
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions doc/stdenv/stdenv.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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];
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 21b6b86

Please sign in to comment.