Understand opam-nix Terminology: Package, Repository, Query, and Scope
mainTo use opam-nix, you must understand its core abstractions which map OCaml/opam concepts to Nix concepts:
- Package: A Nix derivation representing an opam package. It includes a
nix-support/is-opam-nix-packagefile and anix-support/setup-hookfor environment variable propagation. Metadata about the original opam file is stored inpassthru.pkgdef. - Repository: A directory (or derivation producing one) containing
repo/andpackages/directories. Thepackages/directory must follow the structurepackages/<name>/<name>.<version>/<opam-file>. - Query: An attribute set mapping package names to versions (e.g.,
{ pkg = "1.0.0"; }). Use"*"to specify the latest version for functions likeopamList. - Scope: A Nix package set representing an opam switch. It is self-referential, meaning packages within the scope can depend on each other. Note that a scope can only contain one version of any given package due to OCaml linking constraints.