1 # Development Shell helpers {#chap-devShellTools}
3 The `nix-shell` command has popularized the concept of transient shell environments for development or testing purposes.
5 We should try to document the product, not its development process in the Nixpkgs reference manual,
6 but *something* needs to be said to provide context for this library.
7 This is the most future proof sentence I could come up with while Nix itself does yet make use of this.
8 Relevant is the current status of the devShell attribute "project": https://github.com/NixOS/nix/issues/7501
10 However, `nix-shell` is not the only way to create such environments, and even `nix-shell` itself can indirectly benefit from this library.
12 This library provides a set of functions that help create such environments.
14 ## `devShellTools.valueToString` {#sec-devShellTools-valueToString}
16 Converts Nix values to strings in the way the [`derivation` built-in function](https://nix.dev/manual/nix/2.23/language/derivations) does.
19 ## `valueToString` usage examples
22 devShellTools.valueToString (builtins.toFile "foo" "bar")
23 => "/nix/store/...-foo"
27 devShellTools.valueToString false
33 ## `devShellTools.unstructuredDerivationInputEnv` {#sec-devShellTools-unstructuredDerivationInputEnv}
35 Convert a set of derivation attributes (as would be passed to [`derivation`]) to a set of environment variables that can be used in a shell script.
36 This function does not support `__structuredAttrs`, but does support `passAsFile`.
39 ## `unstructuredDerivationInputEnv` usage example
42 devShellTools.unstructuredDerivationInputEnv {
45 buildInputs = [ hello figlet ];
47 args = [ "-c" "${./builder.sh}" ];
52 buildInputs = "/nix/store/...-hello /nix/store/...-figlet";
53 builder = "/nix/store/...-bash";
57 Note that `args` is not included, because Nix does not added it to the builder process environment.
61 ## `devShellTools.derivationOutputEnv` {#sec-devShellTools-derivationOutputEnv}
63 Takes the relevant parts of a derivation and returns a set of environment variables, that would be present in the derivation.
66 ## `derivationOutputEnv` usage example
72 devShellTools.derivationOutputEnv { outputList = pkg.outputs; outputMap = pkg; }