2020-12-25 13:55:36 +00:00
|
|
|
# pkgs.mkShell {#sec-pkgs-mkShell}
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
`pkgs.mkShell` is a specialized `stdenv.mkDerivation` that removes some
|
|
|
|
repetition when using it with `nix-shell` (or `nix develop`).
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
## Usage {#sec-pkgs-mkShell-usage}
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
Here is a common usage example:
|
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
```nix
|
|
|
|
{ pkgs ? import <nixpkgs> {} }:
|
|
|
|
pkgs.mkShell {
|
2021-05-20 23:08:51 +00:00
|
|
|
packages = [ pkgs.gnumake ];
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
inputsFrom = [ pkgs.hello pkgs.gnutar ];
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
export DEBUG=1
|
|
|
|
'';
|
2020-12-25 13:55:36 +00:00
|
|
|
}
|
|
|
|
```
|
2022-01-13 20:06:32 +00:00
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
## Attributes {#sec-pkgs-mkShell-attributes}
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
* `name` (default: `nix-shell`). Set the name of the derivation.
|
|
|
|
* `packages` (default: `[]`). Add executable packages to the `nix-shell` environment.
|
|
|
|
* `inputsFrom` (default: `[]`). Add build dependencies of the listed derivations to the `nix-shell` environment.
|
|
|
|
* `shellHook` (default: `""`). Bash statements that are executed by `nix-shell`.
|
|
|
|
|
|
|
|
... all the attributes of `stdenv.mkDerivation`.
|
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
## Building the shell {#sec-pkgs-mkShell-building}
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
This derivation output will contain a text file that contains a reference to
|
|
|
|
all the build inputs. This is useful in CI where we want to make sure that
|
|
|
|
every derivation, and its dependencies, build properly. Or when creating a GC
|
|
|
|
root so that the build dependencies don't get garbage-collected.
|