diff --git a/README.md b/README.md
index 04bb394..fac364e 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,20 @@
# Nix Pills
-https://nixos.org/nixos/nix-pills/
+Available online as a [multi-page HTML](https://nixos.org/guides/nix-pills/) or an [e-book in EPUB format](https://nixos.org/guides/nix-pills/nix-pills.epub).
-## Development
+You can also build them locally:
+
+ nix-build release.nix -A html-split && firefox result/share/doc/nix-pills/index.html
- - List of Elements: http://tdg.docbook.org/tdg/5.2/chunk-part-d6252e15351.html
- - Tracking Issue: https://github.com/NixOS/nixpkgs/issues/27908
+Similarly, for an [EPUB](https://www.w3.org/publishing/epub32/) version, run:
-When starting a new Pill, comment on the tracking issue which one
-you're doing. If you need help, ask there. If you make progress but
-don't finish in one go, make a PR anyway! I'm trying to not edit
-things as I go, in order to not get bogged down.
+ nix-build release.nix -A epub && foliate result/share/doc/nix-pills/nix-pills.epub
-How I've built and tested:
+## Development
-`nix-build release.nix && firefox result/share/doc/nix-pills/index.html`
+ - [List of DocBook Elements](https://tdg.docbook.org/tdg/5.2/part2.html)
-Emacs config for a nice docbook experience:
+Emacs config for a nice DocBook experience:
```nix
let
diff --git a/book.xml b/book.xml
index d961fea..a160181 100644
--- a/book.xml
+++ b/book.xml
@@ -28,6 +28,9 @@
contributors in 2017.
+
+ For an up-to-date version, please visit . An EPUB version is also available.
+ If you encounter problems, please report them on the
nixos/nix-pills
diff --git a/default.nix b/default.nix
index 19eb6aa..aa4aae2 100644
--- a/default.nix
+++ b/default.nix
@@ -29,7 +29,7 @@ let
cd sources
printf "%s-%s" "$revCount" "$shortRev" > version
- xmllint --xinclude --output $out ./book.xml
+ xmllint --xinclude --output "$out" ./book.xml
'';
toc = builtins.toFile "toc.xml"
@@ -53,34 +53,97 @@ let
"--param chunk.first.sections 1"
"--param use.id.as.filename 1"
"--stringparam generate.toc 'book toc appendix toc'"
- "--stringparam chunk.toc ${toc}"
+ "--stringparam chunk.toc '${toc}'"
];
-in pkgs.stdenv.mkDerivation {
- name = "nix-pills";
+in {
+ html-split = pkgs.stdenv.mkDerivation {
+ name = "nix-pills";
- src = sources;
- buildInputs = with pkgs; [ jing libxslt ];
+ src = sources;
- installPhase = ''
- jing ${pkgs.docbook5}/xml/rng/docbook/docbook.rng $combined
+ buildInputs = with pkgs; [
+ libxslt
+ ];
- # Generate the HTML manual.
- dst=$out/share/doc/nix-pills
- mkdir -p $dst
- xsltproc \
- ${manualXsltprocOptions} \
- --nonet --output $dst/ \
- ${pkgs.docbook-xsl-ns}/xml/xsl/docbook/xhtml/chunk.xsl \
- ${combined}
+ installPhase = ''
+ runHook preInstall
- mkdir -p $dst/images
- cp -r ${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts $dst/images/callouts
+ # Generate the HTML manual.
+ dst=$out/share/doc/nix-pills
+ mkdir -p "$dst"
+ xsltproc \
+ ${manualXsltprocOptions} \
+ --nonet --output "$dst/" \
+ "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/xhtml/chunk.xsl" \
+ "${combined}"
- cp ${./style.css} $dst/style.css
+ mkdir -p "$dst/images/callouts"
+ cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts"/*.svg "$dst/images/callouts"
- mkdir -p $out/nix-support
- echo "nix-build out $out" >> $out/nix-support/hydra-build-products
- echo "doc nix-pills $dst" >> $out/nix-support/hydra-build-products
- '';
+ cp "${./style.css}" "$dst/style.css"
+
+ mkdir -p "$out/nix-support"
+ echo "nix-build out $out" >> "$out/nix-support/hydra-build-products"
+ echo "doc nix-pills $dst" >> "$out/nix-support/hydra-build-products"
+
+ runHook postInstall
+ '';
+ };
+
+ epub = pkgs.stdenv.mkDerivation {
+ name = "nix-pills-epub";
+
+ src = sources;
+
+ buildInputs = with pkgs; [
+ libxslt
+ zip
+ ];
+
+ installCheckInputs = with pkgs; [
+ epubcheck
+ ];
+
+ doInstallCheck = true;
+
+ installPhase = ''
+ runHook preInstall
+
+ # Generate the EPUB manual.
+ dst=$out/share/doc/nix-pills
+ mkdir -p "$dst"
+ xsltproc \
+ ${manualXsltprocOptions} \
+ --nonet --output "$dst/epub/" \
+ "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/epub3/chunk.xsl" \
+ "${combined}"
+
+ mkdir -p "$dst/epub/OEBPS/images/callouts"
+ cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts"/*.svg "$dst/epub/OEBPS/images/callouts"
+ cp "${./style.css}" "$dst/epub/OEBPS/style.css"
+
+ echo "application/epub+zip" > mimetype
+ manual="$dst/nix-pills.epub"
+ zip -0Xq "$manual" mimetype
+ pushd "$dst/epub" && zip -Xr9D "$manual" *
+ popd
+
+ rm -rf "$dst/epub"
+
+ mkdir -p "$out/nix-support"
+ echo "nix-build out $out" >> "$out/nix-support/hydra-build-products"
+ echo "doc-epub nix-pills $manual" >> "$out/nix-support/hydra-build-products"
+
+ runHook postInstall
+ '';
+
+ installCheckPhase = ''
+ runHook preInstallCheck
+
+ epubcheck "$manual"
+
+ runHook postInstallCheck
+ '';
+ };
}
diff --git a/pills/02-install-on-your-running.xml b/pills/02-install-on-your-running.xml
index f5c3e31..ab4679e 100644
--- a/pills/02-install-on-your-running.xml
+++ b/pills/02-install-on-your-running.xml
@@ -21,22 +21,14 @@
- Installing
- Nix is as easy as installing any other package.
- It will not drastically change our system, it will stay out of our way.
+ For installation instructions, please refer to the Nix Reference Manual on
+
+ Installing Nix.
Installation
-
- To install Nix, run curl -L https://nixos.org/nix/install | sh
- as a non-root user and follow the instructions. Alternatively, you may
- prefer to download the installation script and verify its integrity using
- GPG signatures. Instructions for doing so can be found here: https://nixos.org/nix/download.html.
-
-
These articles are not a tutorial on using Nix.
Instead, we're going to walk through the Nix system to understand the fundamentals.
@@ -200,10 +192,9 @@
parse="text" />
- Nix
- expressions are used to describe packages and how to
- build them. Nix language and used to
+ describe packages and how to build them. Nixpkgs is the
repository containing all of the expressions: https://github.com/NixOS/nixpkgs.
diff --git a/pills/06-our-first-derivation.xml b/pills/06-our-first-derivation.xml
index 68bf4ba..bf2855f 100644
--- a/pills/06-our-first-derivation.xml
+++ b/pills/06-our-first-derivation.xml
@@ -42,7 +42,7 @@
- The derivation function receives a set as first argument. This
+ The derivation function receives a set as its first argument. This
set requires at least the following three attributes:
@@ -61,7 +61,7 @@
- builder: it is the binary program that builds the derivation.
+ builder: is the binary program that builds the derivation.
@@ -101,19 +101,19 @@
- .nix files are like .c files
+ .nix files are like .c files.
.drv files are intermediate files like
.o files. The .drv describes
- how to build a derivation, it's the bare minimum information.
+ how to build a derivation; it's the bare minimum information.
- out paths are then the product of the build
+ out paths are then the product of the build.
@@ -127,18 +127,21 @@
better to pretty print it:
-
+
+ If your version of nix doesn't have nix derivation show, use nix show-derivation instead.
+
+
- Ok we can see there's an out path, but it does not exist yet. We never told
+ Ok, we can see there's an out path, but it does not exist yet. We never told
Nix to build it, but we know beforehand where the build output will be. Why?
Think, if Nix ever built the derivation just because we accessed it in Nix,
we would have to wait a long time if it was, say, Firefox. That's why Nix
- let us know the path beforehand and keep evaluating the Nix expressions, but
+ let us know the path beforehand and kept evaluating the Nix expressions, but
it's still empty because no build was ever made.
@@ -252,7 +255,7 @@
- You can guess what builtins.isAttrs does, it returns true if
+ You can guess what builtins.isAttrs does; it returns true if
the argument is a set. While builtins.attrNames returns a list
of keys of the given set. Some kind of reflection, you might say.
@@ -264,9 +267,9 @@
- That's basically the input we gave to the derivation function. Also
+ That's basically the input we gave to the derivation function. Also the
d.name, d.system and d.builder
- attributes are straight the ones we gave as input.
+ attributes are exactly the ones we gave as input.
@@ -286,7 +289,7 @@
Something interesting is the type attribute. It's
"derivation". Nix does add a little of magic to sets with type
- derivation, but not that much. To let you understand, you can create
+ derivation, but not that much. To help you understand, you can create
yourself a set with that type, it's a simple set:
@@ -304,7 +307,7 @@
- The outPath attribute is the build path in the nix store:
+ The outPath attribute is the build path in the nix store:
/nix/store/40s0qmrfb45vlh6610rk29ym318dswdr-myname.
@@ -317,9 +320,9 @@
Just like dependencies in other package managers, how do we refer to other
packages? How do we refer to other derivations in terms of files on the
- disk? We use the outPath. The outPath tells where the files are of that
- derivation. To make it more convenient, Nix is able to do a conversion from
- a derivation set to a string.
+ disk? We use the outPath. The outPath describes
+ the location of the files of that derivation. To make it more convenient,
+ Nix is able to do a conversion from a derivation set to a string.
@@ -457,7 +460,7 @@
Conclusion
- Is it that complicated to create a package for Nix? No it's not.
+ Is it that complicated to create a package for Nix? No, it's not.
@@ -469,8 +472,8 @@
With the derivation function we provide a set of information on how to build
a package, and we get back the information about where the package was
- built. Nix converts a set to a string when there's an outPath, that's very
- convenient. With that, it's easy to refer to other derivations.
+ built. Nix converts a set to a string when there's an outPath;
+ that's very convenient. With that, it's easy to refer to other derivations.
diff --git a/pills/06/examine-build.xml b/pills/06/examine-build.xml
index 6aaa24c..3d88ea0 100644
--- a/pills/06/examine-build.xml
+++ b/pills/06/examine-build.xml
@@ -1,4 +1,4 @@
-$ nix show-derivation /nix/store/qyfrcd53wmc0v22ymhhd5r6sz5xmdc8a-myname.drv
+$ nix derivation show /nix/store/qyfrcd53wmc0v22ymhhd5r6sz5xmdc8a-myname.drv{
"/nix/store/qyfrcd53wmc0v22ymhhd5r6sz5xmdc8a-myname.drv": {
"outputs": {
diff --git a/pills/06/show-derivation.xml b/pills/06/show-derivation.xml
index a90e016..31245a8 100644
--- a/pills/06/show-derivation.xml
+++ b/pills/06/show-derivation.xml
@@ -1,4 +1,4 @@
-$ nix show-derivation /nix/store/z3hhlxbckx4g3n9sw91nnvlkjvyw754p-myname.drv
+$ nix derivation show /nix/store/z3hhlxbckx4g3n9sw91nnvlkjvyw754p-myname.drv{
"/nix/store/z3hhlxbckx4g3n9sw91nnvlkjvyw754p-myname.drv": {
"outputs": {
diff --git a/pills/07-working-derivation.xml b/pills/07-working-derivation.xml
index c78ada1..17d0dac 100644
--- a/pills/07-working-derivation.xml
+++ b/pills/07-working-derivation.xml
@@ -114,6 +114,11 @@
The builder environment
+
+ We can use nix-store --read-log to see the logs our
+ builder produced:
+
+
Let's inspect those environment variables printed during the build process.
@@ -280,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
@@ -294,18 +298,26 @@
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).
- Then we meet the
+ Below is a revised version of the simple.nix file, using the inherit keyword:
+
+
+
+ Here we also take the opportunity to introduce the
inherit keyword.
inherit foo; is equivalent to foo = foo;.
- Similarly, inherit foo bar; is equivalent to foo = foo; bar = bar;.
+ Similarly, inherit gcc coreutils; is equivalent to gcc = gcc; coreutils = coreutils;.
+ Lastly, inherit (pkgs) gcc coreutils; is equivalent to gcc = pkgs.gcc; coreutils = pkgs.coreutils;.
This syntax only makes sense inside sets. There's no magic involved, it's
diff --git a/pills/07/foo.drv.xml b/pills/07/foo.drv.xml
index 81036db..f9a5a92 100644
--- a/pills/07/foo.drv.xml
+++ b/pills/07/foo.drv.xml
@@ -1,4 +1,4 @@
-$ nix show-derivation /nix/store/i76pr1cz0za3i9r6xq518bqqvd2raspw-foo.drv
+$ nix derivation show /nix/store/i76pr1cz0za3i9r6xq518bqqvd2raspw-foo.drv{
"/nix/store/i76pr1cz0za3i9r6xq518bqqvd2raspw-foo.drv": {
"outputs": {
diff --git a/pills/07/read-log.xml b/pills/07/read-log.xml
new file mode 100644
index 0000000..2124383
--- /dev/null
+++ b/pills/07/read-log.xml
@@ -0,0 +1,18 @@
+$ nix-store --read-log /nix/store/gczb4qrag22harvv693wwnflqy7lx5pb-foo
+declare -x HOME="/homeless-shelter"
+declare -x NIX_BUILD_CORES="4"
+declare -x NIX_BUILD_TOP="/tmp/nix-build-foo.drv-0"
+declare -x NIX_LOG_FD="2"
+declare -x NIX_STORE="/nix/store"
+declare -x OLDPWD
+declare -x PATH="/path-not-set"
+declare -x PWD="/tmp/nix-build-foo.drv-0"
+declare -x SHLVL="1"
+declare -x TEMP="/tmp/nix-build-foo.drv-0"
+declare -x TEMPDIR="/tmp/nix-build-foo.drv-0"
+declare -x TMP="/tmp/nix-build-foo.drv-0"
+declare -x TMPDIR="/tmp/nix-build-foo.drv-0"
+declare -x builder="/nix/store/q1g0rl8zfmz7r371fp5p42p4acmv297d-bash-4.4-p19/bin/bash"
+declare -x name="foo"
+declare -x out="/nix/store/gczb4qrag22harvv693wwnflqy7lx5pb-foo"
+declare -x system="x86_64-linux"
diff --git a/pills/07/simple-derivation.xml b/pills/07/simple-derivation.xml
index e82127f..49f3599 100644
--- a/pills/07/simple-derivation.xml
+++ b/pills/07/simple-derivation.xml
@@ -1,27 +1,6 @@
nix-repl> d = derivation { name = "foo"; builder = "${bash}/bin/bash"; args = [ ./builder.sh ]; system = builtins.currentSystem; }nix-repl> :b d
-these derivations will be built:
- /nix/store/i76pr1cz0za3i9r6xq518bqqvd2raspw-foo.drv
-building '/nix/store/i76pr1cz0za3i9r6xq518bqqvd2raspw-foo.drv'...
-declare -x HOME="/homeless-shelter"
-declare -x NIX_BUILD_CORES="4"
-declare -x NIX_BUILD_TOP="/tmp/nix-build-foo.drv-0"
-declare -x NIX_LOG_FD="2"
-declare -x NIX_STORE="/nix/store"
-declare -x OLDPWD
-declare -x PATH="/path-not-set"
-declare -x PWD="/tmp/nix-build-foo.drv-0"
-declare -x SHLVL="1"
-declare -x TEMP="/tmp/nix-build-foo.drv-0"
-declare -x TEMPDIR="/tmp/nix-build-foo.drv-0"
-declare -x TMP="/tmp/nix-build-foo.drv-0"
-declare -x TMPDIR="/tmp/nix-build-foo.drv-0"
-declare -x builder="/nix/store/q1g0rl8zfmz7r371fp5p42p4acmv297d-bash-4.4-p19/bin/bash"
-declare -x name="foo"
-declare -x out="/nix/store/gczb4qrag22harvv693wwnflqy7lx5pb-foo"
-declare -x system="x86_64-linux"
-warning: you did not specify '--add-root'; the result might be removed by the garbage collector
-/nix/store/gczb4qrag22harvv693wwnflqy7lx5pb-foo
+[1 built, 0.0 MiB DL]
this derivation produced the following outputs:
out -> /nix/store/gczb4qrag22harvv693wwnflqy7lx5pb-foo
diff --git a/pills/07/simple.txt b/pills/07/simple.txt
index b975e95..aff3d15 100644
--- a/pills/07/simple.txt
+++ b/pills/07/simple.txt
@@ -1,9 +1,12 @@
-with (import {});
-derivation {
- name = "simple";
- builder = "${bash}/bin/bash";
- args = [ ./simple_builder.sh ];
- inherit gcc coreutils;
- src = ./simple.c;
- system = builtins.currentSystem;
-}
+let
+ pkgs = import {};
+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;
+}
\ No newline at end of file
diff --git a/pills/07/simple_inherit.txt b/pills/07/simple_inherit.txt
new file mode 100644
index 0000000..7abbf03
--- /dev/null
+++ b/pills/07/simple_inherit.txt
@@ -0,0 +1,11 @@
+let
+ pkgs = import {};
+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;
+}
\ No newline at end of file
diff --git a/pills/08-generic-builders.xml b/pills/08-generic-builders.xml
index 8c0ab7b..c7f2b43 100644
--- a/pills/08-generic-builders.xml
+++ b/pills/08-generic-builders.xml
@@ -16,7 +16,7 @@
In this post, we will generalize the builder script, write a Nix expression
for GNU hello world
+ xlink:href="https://www.gnu.org/software/hello/">GNU hello world
and create a wrapper around the derivation built-in function.
@@ -31,10 +31,10 @@
- GNU hello world,
+ GNU hello world,
despite its name, is a simple yet complete project which uses autotools.
Fetch the latest tarball here:
- http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz.
+ https://ftp.gnu.org/gnu/hello/hello-2.12.1.tar.gz.
diff --git a/pills/08/autotools-nix.txt b/pills/08/autotools-nix.txt
index 43264e1..fda44fa 100644
--- a/pills/08/autotools-nix.txt
+++ b/pills/08/autotools-nix.txt
@@ -1,9 +1,8 @@
pkgs: attrs:
- with pkgs;
let defaultAttrs = {
- builder = "${bash}/bin/bash";
+ builder = "${pkgs.bash}/bin/bash";
args = [ ./builder.sh ];
- baseInputs = [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools ];
+ baseInputs = with pkgs; [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools ];
buildInputs = [];
system = builtins.currentSystem;
};
diff --git a/pills/08/hello-builder.txt b/pills/08/hello-builder.txt
index 14787f4..3ad635e 100644
--- a/pills/08/hello-builder.txt
+++ b/pills/08/hello-builder.txt
@@ -1,6 +1,6 @@
export PATH="$gnutar/bin:$gcc/bin:$gnumake/bin:$coreutils/bin:$gawk/bin:$gzip/bin:$gnugrep/bin:$gnused/bin:$bintools/bin"
tar -xzf $src
-cd hello-2.10
+cd hello-2.12.1
./configure --prefix=$out
make
make install
diff --git a/pills/08/hello-nix-darwin.txt b/pills/08/hello-nix-darwin.txt
index be5381b..79e8b1f 100644
--- a/pills/08/hello-nix-darwin.txt
+++ b/pills/08/hello-nix-darwin.txt
@@ -1,11 +1,13 @@
-with (import {});
-derivation {
- name = "hello";
- builder = "${bash}/bin/bash";
- args = [ ./hello_builder.sh ];
- inherit gnutar gzip gnumake coreutils gawk gnused gnugrep;
- gcc = clang;
- binutils = clang.bintools.bintools_bin;
- src = ./hello-2.10.tar.gz;
- system = builtins.currentSystem;
-}
+let
+ pkgs = import {};
+in
+ derivation {
+ name = "hello";
+ builder = "${pkgs.bash}/bin/bash";
+ args = [ ./hello_builder.sh ];
+ inherit (pkgs) gnutar gzip gnumake coreutils gawk gnused gnugrep;
+ gcc = pkgs.clang;
+ bintools = pkgs.clang.bintools.bintools_bin;
+ src = ./hello-2.12.1.tar.gz;
+ system = builtins.currentSystem;
+ }
diff --git a/pills/08/hello-nix-rev-1.txt b/pills/08/hello-nix-rev-1.txt
index 053e715..67b5efd 100644
--- a/pills/08/hello-nix-rev-1.txt
+++ b/pills/08/hello-nix-rev-1.txt
@@ -1,9 +1,11 @@
-with (import {});
-derivation {
- name = "hello";
- builder = "${bash}/bin/bash";
- args = [ ./builder.sh ];
- buildInputs = [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools ];
- src = ./hello-2.10.tar.gz;
- system = builtins.currentSystem;
-}
+let
+ pkgs = import {};
+in
+ derivation {
+ name = "hello";
+ builder = "${pkgs.bash}/bin/bash";
+ args = [ ./builder.sh ];
+ buildInputs = with pkgs; [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools ];
+ src = ./hello-2.12.1.tar.gz;
+ system = builtins.currentSystem;
+ }
diff --git a/pills/08/hello-nix-rev-2.txt b/pills/08/hello-nix-rev-2.txt
index c216fb1..403b783 100644
--- a/pills/08/hello-nix-rev-2.txt
+++ b/pills/08/hello-nix-rev-2.txt
@@ -1,7 +1,8 @@
let
pkgs = import {};
mkDerivation = import ./autotools.nix pkgs;
-in mkDerivation {
- name = "hello";
- src = ./hello-2.10.tar.gz;
-}
+in
+ mkDerivation {
+ name = "hello";
+ src = ./hello-2.12.1.tar.gz;
+ }
diff --git a/pills/08/hello-nix.txt b/pills/08/hello-nix.txt
index 80377bc..ba7f10a 100644
--- a/pills/08/hello-nix.txt
+++ b/pills/08/hello-nix.txt
@@ -1,10 +1,12 @@
-with (import {});
-derivation {
- name = "hello";
- builder = "${bash}/bin/bash";
- args = [ ./hello_builder.sh ];
- inherit gnutar gzip gnumake gcc coreutils gawk gnused gnugrep;
- bintools = binutils.bintools;
- src = ./hello-2.10.tar.gz;
- system = builtins.currentSystem;
-}
+let
+ pkgs = import {};
+in
+ derivation {
+ name = "hello";
+ builder = "${pkgs.bash}/bin/bash";
+ args = [ ./hello_builder.sh ];
+ inherit (pkgs) gnutar gzip gnumake gcc coreutils gawk gnused gnugrep;
+ bintools = pkgs.binutils.bintools;
+ src = ./hello-2.12.1.tar.gz;
+ system = builtins.currentSystem;
+ }
diff --git a/pills/10/autotools-nix.txt b/pills/10/autotools-nix.txt
index a91e254..25b9c07 100644
--- a/pills/10/autotools-nix.txt
+++ b/pills/10/autotools-nix.txt
@@ -1,12 +1,12 @@
pkgs: attrs:
- with pkgs;
let defaultAttrs = {
- builder = "${bash}/bin/bash";
+ builder = "${pkgs.bash}/bin/bash";
args = [ ./builder.sh ];
setup = ./setup.sh;
- baseInputs = [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools patchelf findutils ];
+ baseInputs = with pkgs; [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools patchelf findutils ];
buildInputs = [];
system = builtins.currentSystem;
};
in
-derivation (defaultAttrs // attrs)
+ derivation (defaultAttrs // attrs)
+
diff --git a/pills/10/hello-nix.txt b/pills/10/hello-nix.txt
index c216fb1..bf60ab6 100644
--- a/pills/10/hello-nix.txt
+++ b/pills/10/hello-nix.txt
@@ -2,6 +2,6 @@ let
pkgs = import {};
mkDerivation = import ./autotools.nix pkgs;
in mkDerivation {
- name = "hello";
- src = ./hello-2.10.tar.gz;
-}
+ name = "hello";
+ src = ./hello-2.12.1.tar.gz;
+ }
diff --git a/pills/13/repository-derivation.txt b/pills/13/repository-derivation.txt
index 62e76ca..a5e2c2a 100644
--- a/pills/13/repository-derivation.txt
+++ b/pills/13/repository-derivation.txt
@@ -1,4 +1,4 @@
rec {
lib1 = import package1.nix { inherit input1 input2 ...; };
- program2 = import package1.nix { inherit inputX inputY lib1 ...; };
+ program2 = import package2.nix { inherit inputX inputY lib1 ...; };
}
diff --git a/pills/17-nixpkgs-overriding-packages.xml b/pills/17-nixpkgs-overriding-packages.xml
index ce43350..d885543 100644
--- a/pills/17-nixpkgs-overriding-packages.xml
+++ b/pills/17-nixpkgs-overriding-packages.xml
@@ -97,11 +97,11 @@
- Now we can build e.g. asciidocFull and it will automatically use the overridden graphviz:
+ Now we can build e.g. asciidoc-full and it will automatically use the overridden graphviz:
- Note how we pass the config with packageOverrides when importing nixpkgs. Then pkgs.asciidocFull is a derivation that has graphviz input (pkgs.asciidoc is the lighter version and doesn't use graphviz at all).
+ Note how we pass the config with packageOverrides when importing nixpkgs. Then pkgs.asciidoc-full is a derivation that has graphviz input (pkgs.asciidoc is the lighter version and doesn't use graphviz at all).
Since there's no version of asciidoc with graphviz without X support in the binary cache, Nix will recompile the needed stuff for you.
diff --git a/pills/17/build-asciidoc-graphviz-override.txt b/pills/17/build-asciidoc-graphviz-override.txt
index 1076352..c1c883d 100644
--- a/pills/17/build-asciidoc-graphviz-override.txt
+++ b/pills/17/build-asciidoc-graphviz-override.txt
@@ -1,2 +1,2 @@
nix-repl> pkgs = import { config = import ./config.nix; }
-nix-repl> :b pkgs.asciidocFull
+nix-repl> :b pkgs.asciidoc-full
diff --git a/pills/17/config-nix.txt b/pills/17/config-nix.txt
index 9161ce1..5ed063a 100644
--- a/pills/17/config-nix.txt
+++ b/pills/17/config-nix.txt
@@ -1,5 +1,5 @@
{
packageOverrides = pkgs: {
- graphviz = pkgs.graphviz.override { xorg = null; };
+ graphviz = pkgs.graphviz.override { withXorg = false; };
};
}
diff --git a/pills/17/graphviz-override.txt b/pills/17/graphviz-override.txt
index 4737346..5ecc6c2 100644
--- a/pills/17/graphviz-override.txt
+++ b/pills/17/graphviz-override.txt
@@ -1,4 +1,4 @@
$ nix repl
nix-repl> :l
Added 4360 variables.
-nix-repl> :b graphviz.override { xorg = null; }
+nix-repl> :b graphviz.override { withXorg = false; }
diff --git a/pills/17/p-graphviz-override.txt b/pills/17/p-graphviz-override.txt
index b080079..91984ac 100644
--- a/pills/17/p-graphviz-override.txt
+++ b/pills/17/p-graphviz-override.txt
@@ -1,3 +1,3 @@
pkgs = import {};
-pkgs.graphviz = pkgs.graphviz.override { xorg = null; };
+pkgs.graphviz = pkgs.graphviz.override { withXorg = false; };
build(pkgs.P)
diff --git a/pills/18/bar-derivation.xml b/pills/18/bar-derivation.xml
index 55d3a60..aeb5217 100644
--- a/pills/18/bar-derivation.xml
+++ b/pills/18/bar-derivation.xml
@@ -1,4 +1,4 @@
-$ nix show-derivation /nix/store/ymsf5zcqr9wlkkqdjwhqllgwa97rff5i-bar.drv
+$ nix derivation show /nix/store/ymsf5zcqr9wlkkqdjwhqllgwa97rff5i-bar.drv{
"/nix/store/ymsf5zcqr9wlkkqdjwhqllgwa97rff5i-bar.drv": {
"outputs": {
diff --git a/pills/18/derivation-simple-content.xml b/pills/18/derivation-simple-content.xml
index 9ac8550..9be1bad 100644
--- a/pills/18/derivation-simple-content.xml
+++ b/pills/18/derivation-simple-content.xml
@@ -1,4 +1,4 @@
-$ nix show-derivation /nix/store/y4h73bmrc9ii5bxg6i7ck6hsf5gqv8ck-foo.drv
+$ nix derivation show /nix/store/y4h73bmrc9ii5bxg6i7ck6hsf5gqv8ck-foo.drv{
"/nix/store/y4h73bmrc9ii5bxg6i7ck6hsf5gqv8ck-foo.drv": {
"outputs": {
diff --git a/pills/19-fundamentals-of-stdenv.xml b/pills/19-fundamentals-of-stdenv.xml
index ae6ece6..cea606a 100644
--- a/pills/19-fundamentals-of-stdenv.xml
+++ b/pills/19-fundamentals-of-stdenv.xml
@@ -7,35 +7,35 @@
Fundamentals of Stdenv
- Welcome to the 19th Nix pill. In the previous 18th pill we did dive into the algorithm used by Nix to compute the store paths, and also introduced fixed-output store paths.
+ Welcome to the 19th Nix pill. In the previous 18th pill we dived into the algorithm used by Nix to compute the store paths, and also introduced fixed-output store paths.
- This time we will instead look into nixpkgs, in particular one of its core derivation: stdenv.
+ This time we will instead look into nixpkgs, in particular one of its core derivations: stdenv.
- The stdenv is not a special derivation to Nix, but it's very important for the nixpkgs repository. It serves as base for packaging software. It is used to pull in dependencies such as the GCC toolchain, GNU make, core utilities, patch and diff utilities, and so on. Basic tools needed to compile a huge pile of software currently present in nixpkgs.
+ The stdenv is not treated as a special derivation by Nix, but it's very important for the nixpkgs repository. It serves as a base for packaging software. It is used to pull in dependencies such as the GCC toolchain, GNU make, core utilities, patch and diff utilities, and so on: basic tools needed to compile a huge pile of software currently present in nixpkgs.
- What is stdenv
+ What is stdenv?
- First of all stdenv is a derivation. And it's a very simple one:
+ First of all, stdenv is a derivation, and it's a very simple one:
- It has just two files: /setup and /nix-support/propagated-user-env-packages. Don't care about the latter; it's empty, in fact. The important file is /setup.
+ It has just two files: /setup and /nix-support/propagated-user-env-packages. Don't worry about the latter. It's empty, in fact. The important file is /setup.
- How can this simple derivation pull in all the toolchain and basic tools needed to compile packages? Let's look at the runtime dependencies:
+ How can this simple derivation pull in all of the toolchain and basic tools needed to compile packages? Let's look at the runtime dependencies:
- How can it be? The package must be referring to those package somehow. In fact, they are hardcoded in the /setup file:
+ How can it be? The package must be referring to those other packages somehow. In fact, they are hardcoded in the /setup file:
@@ -48,7 +48,7 @@
- The stdenvsetup file is exactly that. It sets up several environment variables like PATH and creates some helper bash functions to build a package. I invite you to read it, it's only 860 lines at the time of this writing.
+ The stdenv setup file is exactly that. It sets up several environment variables like PATH and creates some helper bash functions to build a package. I invite you to read it.
@@ -60,7 +60,7 @@
- What genericBuild does is just run these phases. Default phases are just bash functions, you can easily read them.
+ What genericBuild does is just run these phases. Default phases are just bash functions. You can easily read them.
@@ -75,19 +75,19 @@
- I unset PATH to further show that the stdenv is enough self-contained to build autotools packages that have no other dependencies.
+ I unset PATH to further show that the stdenv is sufficiently self-contained to build autotools packages that have no other dependencies.
- So we ran the configurePhase function and buildPhase function and they worked. These bash functions should be self-explanatory, you can read the code in the setup file.
+ So we ran the configurePhase function and buildPhase function and they worked. These bash functions should be self-explanatory. You can read the code in the setup file.
- How is the setup file built
+ How the setup file is built
- Until now we worked with plain bash scripts. What about the Nix side? The nixpkgs repository offers a useful function, like we did with our old builder. It is a wrapper around the raw derivation function which pulls in the stdenv for us, and runs genericBuild. It's stdenv.mkDerivation.
+ Until now we worked with plain bash scripts. What about the Nix side? The nixpkgs repository offers a useful function, like we did with our old builder. It is a wrapper around the raw derivation function which pulls in the stdenv for us, and runs genericBuild. It's stdenv.mkDerivation.
@@ -95,7 +95,7 @@
- Let's write a hello.nix expression using this new discovered stdenv:
+ Let's write a hello.nix expression using this newly discovered stdenv:
@@ -140,11 +140,11 @@
- So short I decided to paste it entirely above. The builder is bash, with -e default-builder.sh arguments. Then you can see the src and stdenv environment variables.
+ It's so short I decided to paste it entirely above. The builder is bash, with -e default-builder.sh arguments. Then you can see the src and stdenv environment variables.
- Last bit, the unpackPhase in the setup is used to unpack the sources and enter the directory, again like we did in our old builder.
+ The last bit, the unpackPhase in the setup, is used to unpack the sources and enter the directory. Again, like we did in our old builder.
@@ -167,7 +167,7 @@
- That's it, everything you need to know about the stdenv phases is in the setup file.
+ That's it. Everything you need to know about the stdenv phases is in the setup file.
diff --git a/pills/19/hello-derivation.xml b/pills/19/hello-derivation.xml
index 4152ecf..e0eddc0 100644
--- a/pills/19/hello-derivation.xml
+++ b/pills/19/hello-derivation.xml
@@ -1,4 +1,4 @@
-$ nix show-derivation $(nix-instantiate hello.nix)
+$ nix derivation show $(nix-instantiate hello.nix)warning: you did not specify '--add-root'; the result might be removed by the garbage collector
{
"/nix/store/abwj50lycl0m515yblnrvwyydlhhqvj2-hello.drv": {
diff --git a/pills/20/three-hellos.nix b/pills/20/three-hellos.nix
index e103caf..cc9545b 100644
--- a/pills/20/three-hellos.nix
+++ b/pills/20/three-hellos.nix
@@ -36,6 +36,7 @@ let
mkdir -p "$out/bin"
echo "#! ${stdenv.shell}" >> "$out/bin/hello"
echo "exec $(which hello)" >> "$out/bin/hello"
+ chmod 0755 "$out/bin/hello"
'';
};
diff --git a/pills/20/two-hellos.nix b/pills/20/two-hellos.nix
index d660fc6..f1e7c97 100644
--- a/pills/20/two-hellos.nix
+++ b/pills/20/two-hellos.nix
@@ -24,6 +24,7 @@ let
mkdir -p "$out/bin"
echo "#! ${stdenv.shell}" >> "$out/bin/hello"
echo "exec $(which hello)" >> "$out/bin/hello"
+ chmod 0755 "$out/bin/hello"
'';
};
diff --git a/release.nix b/release.nix
index fb7b57f..7e2bf10 100644
--- a/release.nix
+++ b/release.nix
@@ -5,17 +5,20 @@
let
pkgs = import { };
-in rec {
- html-split = import ./default.nix {
+
+ pills = import ./default.nix {
inherit pkgs;
inherit (nix-pills) revCount shortRev;
};
-
+in rec {
+ inherit (pills) html-split epub;
release = pkgs.releaseTools.aggregate
{ name = "nix-pills-release";
constituents =
- [ html-split
+ [
+ html-split
+ epub
];
meta.description = "All build outputs";
};