Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve a discrepancy in pill 7.7 #222

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions pills/07-working-derivation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,10 @@
Finally, it creates the symlink.
</para>
<para>
In the first line of <filename>simple.nix</filename>, we have an
<function>import</function> function call nested in a <code>with</code>
statement. Recall that <function>import</function> 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 <filename>simple.nix</filename>, we have an
<function>import</function> function call. Recall that <function>import</function>
accepts one argument, a nix file to load. In this case, the contents of
the file evaluate to a function.
</para>
<para>
Afterwards, we call the function with the empty set. We saw this already
Expand All @@ -299,12 +298,15 @@
clearer.
</para>
<para>
The value returned by the nixpkgs function is a set. More specifically,
it's a set of derivations. Using the <code>with</code> expression we bring
them into scope. This is equivalent to the <command>:l &lt;nixpkgs&gt;</command>
we used in <application>nix repl</application>; it allows us to easily access derivations
such as <varname>bash</varname>, <varname>gcc</varname>, and
<varname>coreutils</varname>.
The value returned by the nixpkgs function is a set; more specifically,
it's a set of derivations. Calling <code>import &lt;nixpkgs> {}</code>
into a <function>let</function>-expression creates the local variable
<varname>pkgs</varname> and brings it into scope. This has an effect similar to
the <command>:l &lt;nixpkgs&gt;</command> we used in <application>nix repl</application>,
Comment on lines +304 to +305
Copy link
Member

@jtojnar jtojnar Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the :l mention only makes sense as a reference to with, since both bring the attributes inside pkgs into the scope.

in that it allows us to easily access derivations such as <varname>bash</varname>,
<varname>gcc</varname>, and <varname>coreutils</varname>, but those derivations
will have to be explicitly referred to as members of the <varname>pkgs</varname> set
(e.g., <varname>pkgs.bash</varname> instead of just <varname>bash</varname>).
</para>
<para>
Below is a revised version of the <filename>simple.nix</filename> file, using the <code>inherit</code> keyword:
Expand Down
Loading