From 883191c91d618940f316b2c25afd8a0d2169114b Mon Sep 17 00:00:00 2001 From: Niels Egberts Date: Sat, 10 Jul 2021 14:48:15 +0100 Subject: [PATCH 01/41] Output of declare -xp is no longer visible in the repl Instead nix-store --read-log can be used to see the environment variables. --- pills/07-working-derivation.xml | 5 +++++ pills/07/read-log.xml | 18 ++++++++++++++++++ pills/07/simple-derivation.xml | 23 +---------------------- 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 pills/07/read-log.xml diff --git a/pills/07-working-derivation.xml b/pills/07-working-derivation.xml index ad7726d..ded4fda 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. 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 From 0d7e5019d6fda7c1d2f70c6291f8b422d83da6c9 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 15 Dec 2021 21:13:12 +0100 Subject: [PATCH 02/41] build: Drop DocBook schema validation It was not actually used because we did not pass it the manual. And if we fix it by replacing the Bash `$combined` variable by a Nix one, it will fail because we only have RelaxNG schema for Docbook 5.0, which unlike later versions is too limited (e.g. does not allow emphasis element within filename element). - https://tdg.docbook.org/tdg/5.0/filename.html - https://tdg.docbook.org/tdg/5.2/filename.html --- default.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/default.nix b/default.nix index 19eb6aa..559959a 100644 --- a/default.nix +++ b/default.nix @@ -60,11 +60,9 @@ in pkgs.stdenv.mkDerivation { name = "nix-pills"; src = sources; - buildInputs = with pkgs; [ jing libxslt ]; + buildInputs = with pkgs; [ libxslt ]; installPhase = '' - jing ${pkgs.docbook5}/xml/rng/docbook/docbook.rng $combined - # Generate the HTML manual. dst=$out/share/doc/nix-pills mkdir -p $dst From b4b41c87af64608e6cd1e6378acfabd31fb28fed Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 15 Dec 2021 21:18:25 +0100 Subject: [PATCH 03/41] build: Quote bash variables --- default.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/default.nix b/default.nix index 559959a..6853aa4 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,7 +53,7 @@ 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 { @@ -65,20 +65,20 @@ in pkgs.stdenv.mkDerivation { installPhase = '' # Generate the HTML manual. dst=$out/share/doc/nix-pills - mkdir -p $dst + mkdir -p "$dst" xsltproc \ ${manualXsltprocOptions} \ - --nonet --output $dst/ \ - ${pkgs.docbook-xsl-ns}/xml/xsl/docbook/xhtml/chunk.xsl \ - ${combined} + --nonet --output "$dst/" \ + "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/xhtml/chunk.xsl" \ + "${combined}" - mkdir -p $dst/images - cp -r ${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts $dst/images/callouts + mkdir -p "$dst/images" + cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts" "$dst/images/callouts" - cp ${./style.css} $dst/style.css + 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 + 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" ''; } From 841d008f51ea23c31b93abeccba1f2cd3299a6ea Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 15 Dec 2021 21:19:49 +0100 Subject: [PATCH 04/41] build: Only install svg images --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 6853aa4..535108b 100644 --- a/default.nix +++ b/default.nix @@ -72,8 +72,8 @@ in pkgs.stdenv.mkDerivation { "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/xhtml/chunk.xsl" \ "${combined}" - mkdir -p "$dst/images" - cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts" "$dst/images/callouts" + mkdir -p "$dst/images/callouts" + cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts"/*.svg "$dst/images/callouts" cp "${./style.css}" "$dst/style.css" From 49c3ae87201ebd192c6e69d9d0fdf386fc976c8c Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 15 Dec 2021 21:52:49 +0100 Subject: [PATCH 05/41] build: Add EPUB support You can get it by running `nix-build release.nix -A epub` --- README.md | 2 +- default.nix | 115 ++++++++++++++++++++++++++++++++++++++++------------ release.nix | 11 +++-- 3 files changed, 98 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 04bb394..691a793 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ things as I go, in order to not get bogged down. How I've built and tested: -`nix-build release.nix && firefox result/share/doc/nix-pills/index.html` +`nix-build release.nix -A html-split && firefox result/share/doc/nix-pills/index.html` Emacs config for a nice docbook experience: diff --git a/default.nix b/default.nix index 535108b..aa4aae2 100644 --- a/default.nix +++ b/default.nix @@ -56,29 +56,94 @@ let "--stringparam chunk.toc '${toc}'" ]; -in pkgs.stdenv.mkDerivation { - name = "nix-pills"; - - src = sources; - buildInputs = with pkgs; [ libxslt ]; - - installPhase = '' - # 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}" - - mkdir -p "$dst/images/callouts" - cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts"/*.svg "$dst/images/callouts" - - 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" - ''; +in { + html-split = pkgs.stdenv.mkDerivation { + name = "nix-pills"; + + src = sources; + + buildInputs = with pkgs; [ + libxslt + ]; + + installPhase = '' + runHook preInstall + + # 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}" + + mkdir -p "$dst/images/callouts" + cp -r "${pkgs.docbook-xsl-ns}/xml/xsl/docbook/images/callouts"/*.svg "$dst/images/callouts" + + 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/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"; }; From 9fef24423b0a8087009050305be87e6f5b67aa95 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 15 Dec 2021 22:06:10 +0100 Subject: [PATCH 06/41] Update README The pills are now fully ported so we can drop that line. Also fix list of DocBook elements link and mention EPUB build. --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 691a793..f2bbc2c 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,19 @@ https://nixos.org/nixos/nix-pills/ -## 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 -A html-split && 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 From 94ff26a07ed8bd2e8c1a410d5b92787ed9d5d7d1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 1 Sep 2022 22:18:26 +0200 Subject: [PATCH 07/41] preface: Add EPUB link --- book.xml | 3 +++ 1 file changed, 3 insertions(+) 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 From 234ac869913f75f71e294651a22dbbabfdd6dde5 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 1 Sep 2022 22:20:48 +0200 Subject: [PATCH 08/41] readme: add EPUB link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2bbc2c..fac364e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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). You can also build them locally: From 5cdd76edd50c66f5f2210af98a3ea56728c4ed6b Mon Sep 17 00:00:00 2001 From: James Williams Date: Thu, 23 Feb 2023 22:06:53 +0000 Subject: [PATCH 09/41] fix: typos in 'Our First Derivation' --- pills/06-our-first-derivation.xml | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pills/06-our-first-derivation.xml b/pills/06-our-first-derivation.xml index 68bf4ba..3303721 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. @@ -131,14 +131,14 @@ - 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 +252,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 +264,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 +286,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 +304,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 +317,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 +457,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 +469,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. From ec09dd0d1b5590d9809ef19c9c46b913cd5b092f Mon Sep 17 00:00:00 2001 From: Cyrus Yip <60951091+CyrusYip@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:05:02 +0800 Subject: [PATCH 10/41] Use HTTPS links in 8th pill HTTPS is safer. --- pills/08-generic-builders.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pills/08-generic-builders.xml b/pills/08-generic-builders.xml index 8c0ab7b..2a34f71 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.10.tar.gz. From f0474ddd7facad122b5c4fa54f4cf34bc7f6ebfa Mon Sep 17 00:00:00 2001 From: i97henka Date: Sun, 26 Mar 2023 17:15:49 +0100 Subject: [PATCH 11/41] removing installation instructions Instead refering to original link which links to the Nix manual. --- pills/02-install-on-your-running.xml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pills/02-install-on-your-running.xml b/pills/02-install-on-your-running.xml index f5c3e31..e2f298b 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 this link - + + 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. From 059c9bed554cd24fcdfcc5f8df59618d23935d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Tue, 28 Mar 2023 13:57:29 -0700 Subject: [PATCH 12/41] Pill 8: fix Darwin reference to binutils The Darwin nix still assigns to `binutils`, even though the builder itself was updated to point to `bintools` in ce931b9697343dc781b004834c496edd28b52186. Fixing this ensures the hello example actually builds on Darwin. --- pills/08/hello-nix-darwin.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08/hello-nix-darwin.txt b/pills/08/hello-nix-darwin.txt index be5381b..735d816 100644 --- a/pills/08/hello-nix-darwin.txt +++ b/pills/08/hello-nix-darwin.txt @@ -5,7 +5,7 @@ derivation { args = [ ./hello_builder.sh ]; inherit gnutar gzip gnumake coreutils gawk gnused gnugrep; gcc = clang; - binutils = clang.bintools.bintools_bin; + bintools = clang.bintools.bintools_bin; src = ./hello-2.10.tar.gz; system = builtins.currentSystem; } From 175f64b37de84418d8ac51359072196717a4e110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Thu, 30 Mar 2023 17:16:27 -0700 Subject: [PATCH 13/41] Pill 17: fix graphviz xorg override In the current version of nix, overriding `xorg = null;` no longer seems to work; overriding the `withXorg` attribute allows it to pass instead. --- pills/17/config-nix.txt | 2 +- pills/17/graphviz-override.txt | 2 +- pills/17/p-graphviz-override.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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) From d12bd1b71db7235d77cd41e8c6c9b210b78925ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Fri, 31 Mar 2023 09:58:53 -0700 Subject: [PATCH 14/41] Pill 17: fix asciidoc-full name Attempting to build this as specified in the current docs fails with the error: nix-repl> :b pkgs.asciidocFull error: 'asciidocFull' has been renamed to/replaced by 'asciidoc-full' --- pills/17-nixpkgs-overriding-packages.xml | 4 ++-- pills/17/build-asciidoc-graphviz-override.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 From 560d0beac7c4234055465778a163d5dc3c5f833d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Fri, 31 Mar 2023 12:54:30 -0700 Subject: [PATCH 15/41] Pill 20: allow wrapped hello to be executed As written, this produces a script without the execute bit set, which may confuse users who want to try actually running it after building. --- pills/20/three-hellos.nix | 1 + pills/20/two-hellos.nix | 1 + 2 files changed, 2 insertions(+) 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" ''; }; From f95dd06a92de95f6ae9d7fffc2c0fe334b60957e Mon Sep 17 00:00:00 2001 From: Markus Fuchs Date: Wed, 5 Apr 2023 20:51:47 +0200 Subject: [PATCH 16/41] Pill 13: Fix typo in repository derivation snippet --- pills/13/repository-derivation.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ...; }; } From a6cf5ed410b6eda9350302c824d5a5e9996ab80f Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 6 Apr 2023 18:12:34 +0200 Subject: [PATCH 17/41] fix wording --- pills/02-install-on-your-running.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/02-install-on-your-running.xml b/pills/02-install-on-your-running.xml index e2f298b..8e9be7f 100644 --- a/pills/02-install-on-your-running.xml +++ b/pills/02-install-on-your-running.xml @@ -21,7 +21,7 @@ - For installation instructions, please refer to this link - + For installation instructions, please refer to the Nix Reference Manual on Installing Nix. From 29e1e273b827db169359256f11bf801499c89e4a Mon Sep 17 00:00:00 2001 From: Henrik Date: Fri, 2 Jun 2023 17:17:10 +0100 Subject: [PATCH 18/41] with removed from first line (#213) * with removed from first line example no longer starts with with (import {}); * added inherit example and comments. Co-authored-by: Valentin Gagarin --- pills/07-working-derivation.xml | 9 +++++++-- pills/07/simple.txt | 21 ++++++++++++--------- pills/07/simple_inherit.txt | 11 +++++++++++ 3 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 pills/07/simple_inherit.txt diff --git a/pills/07-working-derivation.xml b/pills/07-working-derivation.xml index d1f44e2..9be1faf 100644 --- a/pills/07-working-derivation.xml +++ b/pills/07-working-derivation.xml @@ -307,10 +307,15 @@ coreutils. - 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/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 From 9ebdbda7a948661a201b0112f7e8f4d0bcaec335 Mon Sep 17 00:00:00 2001 From: i97henka Date: Sat, 3 Jun 2023 15:43:56 +0100 Subject: [PATCH 19/41] updated hello tar gz link. --- pills/08-generic-builders.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08-generic-builders.xml b/pills/08-generic-builders.xml index 2a34f71..596d6cf 100644 --- a/pills/08-generic-builders.xml +++ b/pills/08-generic-builders.xml @@ -34,7 +34,7 @@ GNU hello world, despite its name, is a simple yet complete project which uses autotools. Fetch the latest tarball here: - https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz. + https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz. From b865367523546269eb6f86b5f2bdbc15c576f3e8 Mon Sep 17 00:00:00 2001 From: i97henka Date: Sat, 3 Jun 2023 16:20:54 +0100 Subject: [PATCH 20/41] updating builder new hello version. --- pills/08/hello-builder.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From a826d304a09d11606a9fe3b1d03dc464ce081315 Mon Sep 17 00:00:00 2001 From: i97henka Date: Sat, 3 Jun 2023 16:28:36 +0100 Subject: [PATCH 21/41] changing hello.nix NB Darwin variant still outstanding. --- pills/08/hello-nix.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pills/08/hello-nix.txt b/pills/08/hello-nix.txt index 80377bc..2fc5c74 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 + pkgs.stdenv.mkDerivation { + 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; + } From d4deaeaebe5b2abc94d5b885683bb2d7828f374a Mon Sep 17 00:00:00 2001 From: i97henka Date: Sat, 3 Jun 2023 23:41:45 +0100 Subject: [PATCH 22/41] updated autotools.nix - reduced scope of with. --- pills/08/autotools-nix.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pills/08/autotools-nix.txt b/pills/08/autotools-nix.txt index 43264e1..ba61142 100644 --- a/pills/08/autotools-nix.txt +++ b/pills/08/autotools-nix.txt @@ -1,11 +1,11 @@ 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; }; in - derivation (defaultAttrs // attrs) + pkgs.stdenv.mkDerivation (defaultAttrs // attrs) + From 73658ddd83af4379c15d657c6e997276375993af Mon Sep 17 00:00:00 2001 From: i97henka Date: Sat, 3 Jun 2023 23:48:26 +0100 Subject: [PATCH 23/41] updated third version of hello file. --- pills/08/hello-nix-rev-2.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pills/08/hello-nix-rev-2.txt b/pills/08/hello-nix-rev-2.txt index c216fb1..94c6fec 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 { + mymkDerivation = import ./autotools.nix pkgs; +in +mymkDerivation { name = "hello"; - src = ./hello-2.10.tar.gz; + src = ./hello-2.12.1.tar.gz; } From 5bafd468eb9bcc7835ee262bc328dd05030fe5cd Mon Sep 17 00:00:00 2001 From: i97henka Date: Sun, 4 Jun 2023 00:01:01 +0100 Subject: [PATCH 24/41] changed function name mymkDerivation to avoid collision & confusion with standard function. --- pills/08-generic-builders.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08-generic-builders.xml b/pills/08-generic-builders.xml index 596d6cf..7fbee52 100644 --- a/pills/08-generic-builders.xml +++ b/pills/08-generic-builders.xml @@ -297,7 +297,7 @@ Out of this pill we managed to create a generic builder for autotools - projects, and a function mkDerivation that composes by default + projects, and a function mymkDerivation that composes by default the common components used in autotools projects instead of repeating them in all the packages we would write. From 6bce7954ef726b98bd8b5ef923cfaa991c48d61f Mon Sep 17 00:00:00 2001 From: i97henka Date: Sun, 4 Jun 2023 00:04:42 +0100 Subject: [PATCH 25/41] improved indentation --- pills/08/hello-nix-rev-2.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pills/08/hello-nix-rev-2.txt b/pills/08/hello-nix-rev-2.txt index 94c6fec..410f493 100644 --- a/pills/08/hello-nix-rev-2.txt +++ b/pills/08/hello-nix-rev-2.txt @@ -2,7 +2,7 @@ let pkgs = import {}; mymkDerivation = import ./autotools.nix pkgs; in -mymkDerivation { - name = "hello"; - src = ./hello-2.12.1.tar.gz; -} + mymkDerivation { + name = "hello"; + src = ./hello-2.12.1.tar.gz; + } From b1a8646ce95a32401b4f259ab5fb678a1bf1fb3f Mon Sep 17 00:00:00 2001 From: i97henka Date: Sun, 4 Jun 2023 00:07:16 +0100 Subject: [PATCH 26/41] updated darwin version accordingly. not tested --- pills/08/hello-nix-darwin.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pills/08/hello-nix-darwin.txt b/pills/08/hello-nix-darwin.txt index 735d816..f7423da 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; - bintools = clang.bintools.bintools_bin; - src = ./hello-2.10.tar.gz; - system = builtins.currentSystem; -} +let + pkgs = import {}; +in + pkgs.stdenv.mkDerivation { + 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; + } From 6cdbf506833964c3cdd9f0a272fce8887ead080c Mon Sep 17 00:00:00 2001 From: Henrik Date: Sun, 4 Jun 2023 21:21:20 +0100 Subject: [PATCH 27/41] Update autotools-nix.txt --- pills/08/autotools-nix.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08/autotools-nix.txt b/pills/08/autotools-nix.txt index ba61142..fbd0871 100644 --- a/pills/08/autotools-nix.txt +++ b/pills/08/autotools-nix.txt @@ -2,7 +2,7 @@ pkgs: attrs: let defaultAttrs = { builder = "${pkgs.bash}/bin/bash"; args = [ ./builder.sh ]; - baseInputs = with pkgs; [ 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; }; From f316006776e323719fed0fd68e43fe606c466a13 Mon Sep 17 00:00:00 2001 From: Henrik Date: Sun, 4 Jun 2023 21:21:52 +0100 Subject: [PATCH 28/41] Update autotools-nix.txt --- pills/08/autotools-nix.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/pills/08/autotools-nix.txt b/pills/08/autotools-nix.txt index fbd0871..8fdd6e8 100644 --- a/pills/08/autotools-nix.txt +++ b/pills/08/autotools-nix.txt @@ -8,4 +8,3 @@ pkgs: attrs: }; in pkgs.stdenv.mkDerivation (defaultAttrs // attrs) - From 04337a7e63b495d9138e46562fc1ae6da8fa4df1 Mon Sep 17 00:00:00 2001 From: i97henka Date: Mon, 5 Jun 2023 21:42:34 +0100 Subject: [PATCH 29/41] changing to using builtins derivation and rename renaming to mkDerivation --- pills/08/hello-nix-darwin.txt | 2 +- pills/08/hello-nix-rev-1.txt | 20 +++++++++++--------- pills/08/hello-nix-rev-2.txt | 4 ++-- pills/08/hello-nix.txt | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pills/08/hello-nix-darwin.txt b/pills/08/hello-nix-darwin.txt index f7423da..79e8b1f 100644 --- a/pills/08/hello-nix-darwin.txt +++ b/pills/08/hello-nix-darwin.txt @@ -1,7 +1,7 @@ let pkgs = import {}; in - pkgs.stdenv.mkDerivation { + derivation { name = "hello"; builder = "${pkgs.bash}/bin/bash"; args = [ ./hello_builder.sh ]; 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 410f493..403b783 100644 --- a/pills/08/hello-nix-rev-2.txt +++ b/pills/08/hello-nix-rev-2.txt @@ -1,8 +1,8 @@ let pkgs = import {}; - mymkDerivation = import ./autotools.nix pkgs; + mkDerivation = import ./autotools.nix pkgs; in - mymkDerivation { + 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 2fc5c74..ba7f10a 100644 --- a/pills/08/hello-nix.txt +++ b/pills/08/hello-nix.txt @@ -1,7 +1,7 @@ let pkgs = import {}; in - pkgs.stdenv.mkDerivation { + derivation { name = "hello"; builder = "${pkgs.bash}/bin/bash"; args = [ ./hello_builder.sh ]; From c9b9aae961ca508ea174355f44e7b40bb642a3e5 Mon Sep 17 00:00:00 2001 From: Henrik Date: Tue, 6 Jun 2023 11:28:42 +0100 Subject: [PATCH 30/41] Update autotools-nix.txt now using derivation instead of pkgs.stdenv.mkDerivation --- pills/08/autotools-nix.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08/autotools-nix.txt b/pills/08/autotools-nix.txt index 8fdd6e8..fda44fa 100644 --- a/pills/08/autotools-nix.txt +++ b/pills/08/autotools-nix.txt @@ -7,4 +7,4 @@ pkgs: attrs: system = builtins.currentSystem; }; in - pkgs.stdenv.mkDerivation (defaultAttrs // attrs) + derivation (defaultAttrs // attrs) From c564d1b66378f3b460775758b94c179411def0fa Mon Sep 17 00:00:00 2001 From: i97henka Date: Tue, 6 Jun 2023 17:18:43 +0100 Subject: [PATCH 31/41] updated autotools removed and reduced use of with. --- pills/10/autotools-nix.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pills/10/autotools-nix.txt b/pills/10/autotools-nix.txt index a91e254..4cae7e0 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 patchelf findutils binutils.bintools]; buildInputs = []; system = builtins.currentSystem; }; in -derivation (defaultAttrs // attrs) + derivation (defaultAttrs // attrs) + \ No newline at end of file From ff7c04d0376e3d101496fb2d0e6ba1ecc338e96a Mon Sep 17 00:00:00 2001 From: i97henka Date: Tue, 6 Jun 2023 17:23:31 +0100 Subject: [PATCH 32/41] hello.nix refresh updated tarball version and small change to indentation. --- pills/10/hello-nix.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; + } From 171fc1a4e041edc76f6ca0b42e27f6a484ae8698 Mon Sep 17 00:00:00 2001 From: Henrik Date: Tue, 6 Jun 2023 17:28:31 +0100 Subject: [PATCH 33/41] Update autotools-nix.txt --- pills/10/autotools-nix.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pills/10/autotools-nix.txt b/pills/10/autotools-nix.txt index 4cae7e0..25b9c07 100644 --- a/pills/10/autotools-nix.txt +++ b/pills/10/autotools-nix.txt @@ -3,10 +3,10 @@ pkgs: attrs: builder = "${pkgs.bash}/bin/bash"; args = [ ./builder.sh ]; setup = ./setup.sh; - baseInputs = with pkgs; [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep patchelf findutils binutils.bintools]; + baseInputs = with pkgs; [ gnutar gzip gnumake gcc coreutils gawk gnused gnugrep binutils.bintools patchelf findutils ]; buildInputs = []; system = builtins.currentSystem; }; in derivation (defaultAttrs // attrs) - \ No newline at end of file + From 7dcefdec89ebc860852295bb24c062420d139adb Mon Sep 17 00:00:00 2001 From: Henrik Date: Tue, 6 Jun 2023 21:28:49 +0100 Subject: [PATCH 34/41] updated patchelf link to github (#215) --- pills/09-automatic-runtime.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/09-automatic-runtime.xml b/pills/09-automatic-runtime.xml index e6ea80f..f236cc5 100644 --- a/pills/09-automatic-runtime.xml +++ b/pills/09-automatic-runtime.xml @@ -143,7 +143,7 @@ The build process adds that gcc lib path thinking it may be useful at runtime, but really it's not. How do we get rid of it? Nix authors have written another magical tool called - patchelf, which + patchelf, which is able to reduce the rpath to the paths that are really used by the binary. From e1b2be6893ec6403ad4690721d1e4474526953d2 Mon Sep 17 00:00:00 2001 From: Henrik Date: Thu, 22 Jun 2023 07:49:45 +0100 Subject: [PATCH 35/41] Update pills/08-generic-builders.xml Co-authored-by: Zach Mitchell, PhD --- pills/08-generic-builders.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08-generic-builders.xml b/pills/08-generic-builders.xml index 7fbee52..fe70c11 100644 --- a/pills/08-generic-builders.xml +++ b/pills/08-generic-builders.xml @@ -34,7 +34,7 @@ GNU hello world, despite its name, is a simple yet complete project which uses autotools. Fetch the latest tarball here: - https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz. + https://ftp.gnu.org/gnu/hello/hello-2.12.1.tar.gz. From 961fa9fed41cbbb96e27bb62db8285ad2be2ebbd Mon Sep 17 00:00:00 2001 From: Andrew Bruce Date: Sat, 15 Jul 2023 18:22:19 +0100 Subject: [PATCH 36/41] Grammatical adjustments to Nix Pill 19 (#218) - tense corrections e.g. "did dive" -> "dived" - pluralisation corrections - "is not a special derivation to Nix" -> "is not treated as a special derivation by Nix" - add question marks to headings phrased as questions, or transform them into statements - sentence separation and removal of semicolons - adverb corrections e.g. "enough contained" -> "sufficiently contained" - links to sources in GitHub where they felt frustratingly missing --- pills/19-fundamentals-of-stdenv.xml | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 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, 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. From b54b78be8030df398540056fc3e07c29ee38a32e Mon Sep 17 00:00:00 2001 From: Arek Kalandyk <36413794+koralowiec@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:17:02 +0200 Subject: [PATCH 37/41] fix(typo): rename mymkDerivation to mkDerivation in conclusion of pill 08 (#220) --- pills/08-generic-builders.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/08-generic-builders.xml b/pills/08-generic-builders.xml index fe70c11..c7f2b43 100644 --- a/pills/08-generic-builders.xml +++ b/pills/08-generic-builders.xml @@ -297,7 +297,7 @@ Out of this pill we managed to create a generic builder for autotools - projects, and a function mymkDerivation that composes by default + projects, and a function mkDerivation that composes by default the common components used in autotools projects instead of repeating them in all the packages we would write. 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 38/41] 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: From 9ab4662818a625eea845b401830cb2092f02563d Mon Sep 17 00:00:00 2001 From: Wout De Puysseleir Date: Wed, 25 Oct 2023 14:23:20 -0700 Subject: [PATCH 39/41] show-derivation -> derivation show It looks like the command `nix show-derivation` is deprecated in favor of `nix derivation show` This replaces all instances of `show-derivation` with `derivation show` --- pills/06/examine-build.xml | 2 +- pills/06/show-derivation.xml | 2 +- pills/07/foo.drv.xml | 2 +- pills/18/bar-derivation.xml | 2 +- pills/18/derivation-simple-content.xml | 2 +- pills/19/hello-derivation.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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/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/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/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": { From ae36c178a3a459e5125c5b43fcd97290e602513a Mon Sep 17 00:00:00 2001 From: Wout De Puysseleir Date: Wed, 25 Oct 2023 15:07:34 -0700 Subject: [PATCH 40/41] Add note about using nix show-derivation instead --- pills/06-our-first-derivation.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pills/06-our-first-derivation.xml b/pills/06-our-first-derivation.xml index 3303721..bf2855f 100644 --- a/pills/06-our-first-derivation.xml +++ b/pills/06-our-first-derivation.xml @@ -127,8 +127,11 @@ 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 From 7a15f1f396f4688243f135a5c2e775bb21c28c5a Mon Sep 17 00:00:00 2001 From: Henrik Karlsson Date: Sat, 6 Jan 2024 18:57:30 +0000 Subject: [PATCH 41/41] fixing broken writing nix expressions link. (second attempt) --- pills/02-install-on-your-running.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pills/02-install-on-your-running.xml b/pills/02-install-on-your-running.xml index 8e9be7f..ab4679e 100644 --- a/pills/02-install-on-your-running.xml +++ b/pills/02-install-on-your-running.xml @@ -192,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.