From f472aaf28e6a6f45faca627b2c3daa24dbb873ac Mon Sep 17 00:00:00 2001 From: Pegasust Date: Tue, 29 Aug 2023 13:38:30 -0700 Subject: [PATCH] docs: add what-to-do for cargo/rust-related problems --- docs/edgecases.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/docs/edgecases.md b/docs/edgecases.md index e49f2783f..b1277c658 100644 --- a/docs/edgecases.md +++ b/docs/edgecases.md @@ -220,6 +220,75 @@ Resulting override: } ``` +#### Errors that are related to Rust and Cargo + +**Please update `getCargoHash` and there is a stanza that gives out the hash** + +This has known solution https://github.com/nix-community/poetry2nix/pull/1116 + +Though, the solution still needs human-in-a-loop as there are many cases where +there is no expected hash provided. + +There are then 2 ways you can solve this while waiting for the PR to merge: + +1. Pin the package to a previous working version + +This works for transitive package as well, say you have `foo` that depends on +`bar 1.0.1`, but we have `getCargoHash` for `bar 1.0.0`. You can pin `bar` +on your `pyproject.toml` directly + +```toml +# pyproject.toml +[tool.poetry.dependencies] +#... +# NB: this must be = and without any `^` prefix +bar = "1.0.0" +``` + +(Remember to `poetry lock`) + +2. Pin `poetry2nix` to your branch + +If you have created a PR, you probably have a fork of `poetry2nix` under your branch. +In this case, assuming you use `flake`, here's an insight on what this would look +like + +```nix +# flake.nix +{ + inputs.poetry2nix.url = "github:your-username/poetry2nix/add-bar-1_0_1"; + inputs.nixpkgs.url = "your-pinned-nixpkgs"; + outputs = {nixpkgs, poetry2nix, ...}: let + # NOTE: your mileage may vary, if you use other flake frameworks like flake-utils + # or flake-parts, you should have `pkgs` or `pkgs'` + pkgs = import nixpkgs {system = "your-system";}; + pkgs_overriden = pkgs.appendOverlays [poetry2nix.overlay]; + in { + packages = pkgs_overriden.poetry2nix.mkPoetryApplication { + projectDir = ./.; + }; + }; +} +``` + +**Use `preferWheels` and call it a day** + +We have many issues come in thanks to the recent boom of maturin and setuptools-rust. + +While the ecosystem is growing, we have an escape hatch to use `preferWheels` +if you trust pip wheel dists. `preferWheels` is basically Python's version of +compiled binary, so it is vulnerable to supply chain attacks. + + +```nix +poetry2nix.mkPoetryApplication { + projectDir = ./.; + preferWheels = true; +} +``` + +Though, we would really appreciate a GitHub issue for your use-case. + #### Nix evaluation errors 1. Enable `--show-trace`. @@ -239,4 +308,4 @@ error: infinite recursion encountered … while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.11-main-0.1.0' ``` -This is because `dask[distributed]` depends on `distributed` which depends on `dask`. The solution is to install `dask` (no extras) and `distributed` separately. \ No newline at end of file +This is because `dask[distributed]` depends on `distributed` which depends on `dask`. The solution is to install `dask` (no extras) and `distributed` separately.