- Publication and Update Dates: Published on 25 Apr. 2025 and last updated on 2 May. 2025.
- Opam Issue and Pull Request: Three years ago (22 Apr 2022), an issue was opened in the OCaml package manager, opam, regarding depext not supporting nixOS. Last week, the pull request to fix this was merged.
- Let's Encrypt Example Before: When installing an OCaml package with a system dependency using opam 2.3.0, it would encounter errors like the compilation of conf-gmp failing due to a missing gmp.h file.
- Let's Encrypt Example After: With opam 2.4.0~alpha1, it shows that the system packages gmp and pkg-config need to be installed first. opam then uses opam-nix to handle external dependencies and provides system dependencies from Nixpkgs.
Implementation Details:
- opam has an external dependency system where packages can declare dependencies on system package managers. The opam repository has virtual
conf-*
packages. - NixOS has a different notion of installation, and attempts to invoke
nix-env
for Nix system dependencies were limited to executables. - opam-nix was used to build binaries as Nix derivations to make them GC roots and handle dependencies. A Nix derivation was created in opam to output an environment file with variables to make depexts available.
- This depext mechanism doesn't interfere with the system environment and allows isolated environments for different projects.
- opam has an external dependency system where packages can declare dependencies on system package managers. The opam repository has virtual
- Usage and Overlays: Opam 2.4~alpha1 with Nix depext mechanism can be used on NixOS with a specific overlay. It can also be used directly from a repository with a command like
nix shell github:RyanGibb/nixos#legacyPackages.x86_64-linux.nixpkgs.opam
. - Other Work: Another part of the project was bridging version solving with Nix in opam-nix-repository, which continued into the Enki project. Thanks are given to David, Kate, Raja, and Jane Street for their help.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。