nix-playgraound/notes/022-devshell-vs-shellfor.md

41 lines
912 B
Markdown
Raw Normal View History

# Dev Shell versus shellFor
This note covers `19-devshell-vs-shellfor/`, which builds one local package and exposes two dev shells around it.
---
## 1. What Is Being Compared
The example defines:
- `devShells.<system>.generic`, built with `pkgs.mkShell`, and
- `devShells.<system>.shellFor`, built with `haskellPackages.shellFor`.
Both shells support the same local package, but they are assembled differently.
---
## 2. Why the Difference Matters
`mkShell` is generic. You list tools directly.
`shellFor` is package-set-aware. It starts from Haskell packages and builds a shell around their dependencies.
That makes `shellFor` more tightly coupled to the package graph, while `mkShell` stays more explicit and general-purpose.
---
## 3. Commands to Try
```bash
cd 19-devshell-vs-shellfor
nix develop .#generic
nix develop .#shellFor
nix build
./result/bin/mini-shell-choice
nix flake check
```