From cefdfa8ee1aa40b8215a5dfdd3ba894a1a069bc2 Mon Sep 17 00:00:00 2001 From: MathiasMalandain <98515824+MathiasMalandain@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:27:58 +0200 Subject: [PATCH] Update the description of simple.nix in pill 7.7 Solve the discrepancy between the code and its description --- pills/07-working-derivation.xml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pills/07-working-derivation.xml b/pills/07-working-derivation.xml index 9be1faf..17d0dac 100644 --- a/pills/07-working-derivation.xml +++ b/pills/07-working-derivation.xml @@ -285,11 +285,10 @@ Finally, it creates the symlink. - In the first line of simple.nix, we have an - import function call nested in a with - statement. Recall that import accepts one argument, a - nix file to load. In this case, the contents of the file evaluated to a - function. + In the second line of simple.nix, we have an + import function call. Recall that import + accepts one argument, a nix file to load. In this case, the contents of + the file evaluate to a function. Afterwards, we call the function with the empty set. We saw this already @@ -299,12 +298,15 @@ clearer. - The value returned by the nixpkgs function is a set. More specifically, - it's a set of derivations. Using the with expression we bring - them into scope. This is equivalent to the :l <nixpkgs> - we used in nix repl; it allows us to easily access derivations - such as bash, gcc, and - coreutils. + The value returned by the nixpkgs function is a set; more specifically, + it's a set of derivations. Calling import <nixpkgs> {} + into a let-expression creates the local variable + pkgs and brings it into scope. This has an effect similar to + the :l <nixpkgs> we used in nix repl, + in that it allows us to easily access derivations such as bash, + gcc, and coreutils, but those derivations + will have to be explicitly referred to as members of the pkgs set + (e.g., pkgs.bash instead of just bash). Below is a revised version of the simple.nix file, using the inherit keyword: