diff --git a/pills/20-basic-dependencies-and-hooks.xml b/pills/20-basic-dependencies-and-hooks.xml index 4bdfe0d..3b021d1 100644 --- a/pills/20-basic-dependencies-and-hooks.xml +++ b/pills/20-basic-dependencies-and-hooks.xml @@ -21,13 +21,11 @@ Together, these 4 concepts support almost all build-time package interactions. - - This Nix pill is going to teach Nixpkgs a bit differently. - The Nix pills before this one have used the most recent version of Nixpkgs when discussing it. - But the dependencies and hooks infrastructure has for a few years been increasingly complicated to support cross compilation, with a final boost of complexity in recently in 2017. - While the added mechanism shouldn't be too confusing after the core concepts are taught, they just get in the way before, so this Nix Pill will go all the way back to 2009 with commit 6675f0a5. - This is the last version of stdenv before extra dependency and hook types for cross compilation were created. - + + The complexity of the dependencies and hooks infrastructure has increased, over time, to support cross compilation. + Once you learn the core concepts, you will be able to understand the extra complexity. + As a starting point, you might want to refer to nixpkgs commit 6675f0a5, the last version of stdenv without cross-compilation complexity. +
The <varname>buildInputs</varname> Attribute @@ -40,6 +38,7 @@ + Notice that the wrappedHello derivation finds the hello binary from the PATH. This works because stdenv contains something like: where findInputs is defined like: @@ -50,8 +49,10 @@ The addToSearchPath call adds $1/bin to _PATH if the former exists (code here). + Once all the packages in buildInputs have been processed, then content of _PATH is added to PATH, as follows: + - With the real hello on the path, the installPhase should hopefully make sense. + With the real hello on the PATH, the installPhase should hopefully make sense.
@@ -147,7 +148,7 @@ indeed that's just what we do in CC Wrapper. - . It was called GCC Wrapper in the version of nixpkgs we're using in this pill; Darwin and Clang support hadn't yet motivated the rename. + It was called GCC Wrapper in the version of nixpkgs suggested for following along in this pill; Darwin and Clang support hadn't yet motivated the rename. But this pattern comes up fairly often, so somebody decided to add some helper support to reduce boilerplate. diff --git a/pills/20/build-inputs-4.bash b/pills/20/build-inputs-4.bash new file mode 100644 index 0000000..ff883ce --- /dev/null +++ b/pills/20/build-inputs-4.bash @@ -0,0 +1 @@ +PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH" diff --git a/pills/20/three-hellos.nix b/pills/20/three-hellos.nix index 246c130..e103caf 100644 --- a/pills/20/three-hellos.nix +++ b/pills/20/three-hellos.nix @@ -1,10 +1,8 @@ let - nixpkgs = import (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/6675f0a52c0962042a1000c7f20e887d0d26ae25.tar.gz"; - }) {}; + nixpkgs = import {}; - inherit (nixpkgs) stdenv fetchurl; + inherit (nixpkgs) stdenv fetchurl which; actualHello = stdenv.mkDerivation { name = "hello-2.3"; @@ -20,6 +18,8 @@ let propagatedBuildInputs = [ actualHello ]; + unpackPhase = "true"; + installPhase = '' mkdir -p "$out" ''; @@ -28,7 +28,9 @@ let wrappedHello = stdenv.mkDerivation { name = "hello-wrapper"; - buildInputs = [ intermediary ]; + buildInputs = [ intermediary which ]; + + unpackPhase = "true"; installPhase = '' mkdir -p "$out/bin" diff --git a/pills/20/two-hellos.nix b/pills/20/two-hellos.nix index 6e5d309..d660fc6 100644 --- a/pills/20/two-hellos.nix +++ b/pills/20/two-hellos.nix @@ -1,10 +1,8 @@ let - nixpkgs = import (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/6675f0a52c0962042a1000c7f20e887d0d26ae25.tar.gz"; - }) {}; + nixpkgs = import {}; - inherit (nixpkgs) stdenv fetchurl; + inherit (nixpkgs) stdenv fetchurl which; actualHello = stdenv.mkDerivation { name = "hello-2.3"; @@ -18,7 +16,9 @@ let wrappedHello = stdenv.mkDerivation { name = "hello-wrapper"; - buildInputs = [ actualHello ]; + buildInputs = [ actualHello which ]; + + unpackPhase = "true"; installPhase = '' mkdir -p "$out/bin"