1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 14:32:43 -04:00

Merge pull request #621 from CyberShadow/patch-1

tutorials/first-steps/nix-language: Fix the nixpkgs example
This commit is contained in:
Valentin Gagarin 2023-09-14 15:24:30 +02:00 committed by GitHub
commit 68839d3d60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1995,7 +1995,7 @@ Explanation:
### Package
```{code-block} nix
{ lib, stdenv }:
{ lib, stdenv, fetchurl }:
stdenv.mkDerivation rec {
@ -2003,7 +2003,7 @@ stdenv.mkDerivation rec {
version = "2.12";
src = builtins.fetchTarball {
src = fetchurl {
url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz";
sha256 = "1ayhp9v4m4rdhjmnl2bq3cibrbqqkgjbl3s7yk2nhlh8vj3ay16g";
};
@ -2019,9 +2019,10 @@ This example is a (simplified) package declaration from Nixpkgs.
Explanation:
- This expression is a function that takes an attribute set which must have exactly the attributes `lib` and `stdenv`.
- This expression is a function that takes an attribute set which must have exactly the attributes `lib`, `stdenv`, and `fetchurl`.
- It returns the result of evaluating the function `mkDerivation`, which is an attribute of `stdenv`, applied to a recursive set.
- The recursive set passed to `mkDerivation` uses its own `pname` and `version` attributes in the argument to the built-in function `fetchTarball`.
- The recursive set passed to `mkDerivation` uses its own `pname` and `version` attributes in the argument to the function `fetchurl`.
`fetchurl` itself comes from the outer function's arguments.
- The `meta` attribute is itself an attribute set, where the `license` attribute has the value that was assigned to the nested attribute `lib.licenses.gpl3Plus`.
## References