# Packages built by other languages' tools How [pkgs/haskell] and [pkgs/rust] find a package's source and its plan, and why. A new overlay of the kind (pkgs/LANGUAGE) follows the same rules. ## Where a package's source comes from The first that applies: 1. A checkout, ~/sync/src/NAME, where there is one. It wins over the package in hrm, so that a change in a checkout can be deployed right away. Without a package in hrm, the checkout becomes one anyway (an automatic package), so an experiment in ~/sync/src can be deployed by adding a module to hrm. 2. The source pinned in [sources.json], as delivered to /var/src/NAME. 3. The system's NIX_PATH, if neither. The same goes for the sources hrm takes as inputs ([legacy.nix]), but for nixpkgs, which always comes from NIX_PATH. ## Plans A plan is what a language's tool works out from the project, saved so that evaluation needn't run the tool (by import from derivation, which is slow): - Haskell: the package itself, as cabal2nix makes it. [pkgs/haskell] holds these; a checkout may have its own, cabal.nix. - Rust: crate2nix's Cargo.json. A plan lives next to the source it was made for: - pkgs/rust/NAME/Cargo.json, for the package in hrm; - ~/sync/src/NAME/Cargo.json or cabal.nix, for a checkout; - the delivered source's own, /Cargo.json, if it has one. The source's own plan wins: a checkout uses its own, never the one in hrm. A missing plan means the tool runs during evaluation: slower, never wrong. A stale plan stops evaluation. A package file in [pkgs/rust] names its source as it is. The overlay copies it into the store for the build, leaving Cargo.lock out next to a Cargo.json, and checks the plan against the source itself. [plans] says which plans are current, stale, missing or unused, and makes them again: the Rust plans in hrm, unused ones too, as they apply where there's no checkout, and the plans in checkouts, never those in delivered sources. [legacy.nix]: ../legacy.nix [pkgs/haskell]: haskell [pkgs/rust]: rust [plans]: shell/plans [sources.json]: ../sources.json