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

with removed from first line #213

Merged
merged 4 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions pills/07-working-derivation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,15 @@
<varname>coreutils</varname>.
</para>
<para>
Then we meet the
Below is a revised version of the <filename>simple.nix</filename> file, using the <code>inherit</code> keyword:

<programlisting><xi:include href="./07/simple_inherit.txt" parse="text" /></programlisting>

Here we also take the opportunity to introduce the
<link xlink:href="https://nixos.org/manual/nix/stable/expressions/language-constructs.html#inheriting-attributes"><code>inherit</code> keyword</link>.
<code>inherit foo;</code> is equivalent to <code>foo = foo;</code>.
Similarly, <code>inherit foo bar;</code> is equivalent to <code>foo = foo; bar = bar;</code>.
Similarly, <code>inherit gcc coreutils;</code> is equivalent to <code> gcc = gcc; coreutils = coreutils;</code>.
Lastly, <code>inherit (pkgs) gcc coreutils;</code> is equivalent to <code> gcc = pkgs.gcc; coreutils = pkgs.coreutils;</code>.
</para>
<para>
This syntax only makes sense inside sets. There's no magic involved, it's
Expand Down
21 changes: 12 additions & 9 deletions pills/07/simple.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
with (import <nixpkgs> {});
derivation {
name = "simple";
builder = "${bash}/bin/bash";
args = [ ./simple_builder.sh ];
inherit gcc coreutils;
src = ./simple.c;
system = builtins.currentSystem;
}
let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation {
name = "simple";
builder = "${pkgs.bash}/bin/bash";
args = [ ./simple_builder.sh ];
gcc = pkgs.gcc;
coreutils = pkgs.coreutils;
src = ./simple.c;
system = builtins.currentSystem;
}
11 changes: 11 additions & 0 deletions pills/07/simple_inherit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation {
name = "simple";
builder = "${pkgs.bash}/bin/bash";
args = [ ./simple_builder.sh ];
inherit (pkgs) gcc coreutils;
src = ./simple.c;
system = builtins.currentSystem;
}