doc: make `sourceRoot` and `setSourceRoot` documentation match the implementation, fix examples

+8 -3
+1 -1
doc/languages-frameworks/rust.section.md
··· 558 hash = "sha256-miW//pnOmww2i6SOGbkrAIdc/JMDT4FJLqdMFojZeoY="; 559 }; 560 561 - sourceRoot = "source/bindings/python"; 562 563 nativeBuildInputs = [ 564 cargo
··· 558 hash = "sha256-miW//pnOmww2i6SOGbkrAIdc/JMDT4FJLqdMFojZeoY="; 559 }; 560 561 + sourceRoot = "${src.name}/bindings/python"; 562 563 nativeBuildInputs = [ 564 cargo
+7 -2
doc/stdenv/stdenv.chapter.md
··· 614 615 ##### `sourceRoot` {#var-stdenv-sourceRoot} 616 617 - After running `unpackPhase`, the generic builder changes the current directory to the directory created by unpacking the sources. If there are multiple source directories, you should set `sourceRoot` to the name of the intended directory. Set `sourceRoot = ".";` if you use `srcs` and control the unpack phase yourself. 618 619 - By default the `sourceRoot` is set to `"source"`. If you want to point to a sub-directory inside your project, you therefore need to set `sourceRoot = "source/my-sub-directory"`. 620 621 ##### `setSourceRoot` {#var-stdenv-setSourceRoot} 622 623 Alternatively to setting `sourceRoot`, you can set `setSourceRoot` to a shell command to be evaluated by the unpack phase after the sources have been unpacked. This command must set `sourceRoot`. 624 625 ##### `preUnpack` {#var-stdenv-preUnpack} 626
··· 614 615 ##### `sourceRoot` {#var-stdenv-sourceRoot} 616 617 + After unpacking all of `src` and `srcs`, if neither of `sourceRoot` and `setSourceRoot` are set, `unpackPhase` of the generic builder checks that the unpacking produced a single directory and moves the current working directory into it. 618 + 619 + If `unpackPhase` produces multiple source directories, you should set `sourceRoot` to the name of the intended directory. 620 + You can also set `sourceRoot = ".";` if you want to control it yourself in a later phase. 621 622 + For example, if your want your build to start in a sub-directory inside your sources, and you are using `fetchzip`-derived `src` (like `fetchFromGitHub` or similar), you need to set `sourceRoot = "${src.name}/my-sub-directory"`. 623 624 ##### `setSourceRoot` {#var-stdenv-setSourceRoot} 625 626 Alternatively to setting `sourceRoot`, you can set `setSourceRoot` to a shell command to be evaluated by the unpack phase after the sources have been unpacked. This command must set `sourceRoot`. 627 + 628 + For example, if you are using `fetchurl` on an archive file that gets unpacked into a single directory the name of which changes between package versions, and you want your build to start in its sub-directory, you need to set `setSourceRoot = "sourceRoot=$(echo */my-sub-directory)";`, or in the case of multiple sources, you could use something more specific, like `setSourceRoot = "sourceRoot=$(echo ${pname}-*/my-sub-directory)";`. 629 630 ##### `preUnpack` {#var-stdenv-preUnpack} 631