Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: don't recommend listing packages with nix-env #317392

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make a proper example
  • Loading branch information
fricklerhandwerk committed Jun 5, 2024
commit 71f0dc5650ede803ed383d32ffaf6525f6f7e63f
29 changes: 27 additions & 2 deletions doc/languages-frameworks/haskell.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,37 @@ set and are re-exposed with a reduced dependency closure for convenience.
(see `justStaticExecutables` or `separateBinOutput` below)

The `haskellPackages` set includes at least one version of every package from [Hackage](https://hackage.haskell.org/) as well as some manually injected packages.
Haskell packages can be searched on [search.nixos.org](https://search.nixos.org/packages?query=haskellPackages) or listed on the command line with [`nix-instantiate`](https://nixos.org/manual/nix/stable/command-ref/nix-instantiate):
Haskell packages can be searched on [search.nixos.org](https://search.nixos.org/packages?query=haskellPackages) or listed on the command line with [`nix-instantiate`](https://nixos.org/manual/nix/stable/command-ref/nix-instantiate).

:::{.example #example-list-haskellPackages}

# List all Haskell packages in Nixpkgs

The follwowing command evaluates a Nix expression that maps names of Haskell packages to their version, and displays the result as a JSON.

```shell-session
nix-instantiate --eval -E 'builtins.attrNames (import <nixpkgs> {}).haskellPackages' --json | jq -r '.[]'
nix-instantiate --strict --eval --json --expr "$(cat << EOF
with (import <nixpkgs> {}); with lib;
mapAttrs (k: v: v.version)
(filterAttrs (k: v: isDerivation v) haskellPackages)
EOF
)" | jq . | head -10
```

```console
{
"2captcha": "0.1.0.0",
"3d-graphics-examples": "0.0.0.2",
"3dmodels": "0.3.0",
"4Blocks": "0.2",
"AAI": "0.2.0.1",
"ABList": "0.0.3",
"AC-Angle": "1.0",
"AC-Boolean": "1.1.0",
"AC-BuildPlatform": "1.1.0",
```
:::

The attribute names in `haskellPackages` always correspond with their name on
Hackage. Since Hackage allows names that are not valid Nix without escaping,
you need to take care when handling attribute names like `3dmodels`.
Expand Down