|
| 1 | +# Copyright lowRISC Contributors. |
| 2 | +# Licensed under the MIT License, see LICENSE for details. |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | +{pkgs, ...}: let |
| 5 | + # https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md |
| 6 | + # poetry2nix tries to build the python packages based on the information |
| 7 | + # given in their own build description files (setup.py etc.) |
| 8 | + # Sometimes, the inputs are incomplete. Add missing inputs here. |
| 9 | + pypkgs-missing-build-requirements = { |
| 10 | + # package: build-requirements # |
| 11 | + attrs = ["hatchling" "hatch-fancy-pypi-readme" "hatch-vcs"]; |
| 12 | + beautifulsoup4 = ["hatchling"]; |
| 13 | + pyfinite = ["setuptools"]; |
| 14 | + zipfile2 = ["setuptools"]; |
| 15 | + okonomiyaki = ["setuptools"]; |
| 16 | + simplesat = ["setuptools"]; |
| 17 | + urllib3 = ["hatchling"]; |
| 18 | + fusesoc = ["setuptools" "setuptools-scm"]; |
| 19 | + chipwhisperer = ["setuptools"]; |
| 20 | + siphash = ["setuptools"]; |
| 21 | + tockloader = ["setuptools"]; |
| 22 | + }; |
| 23 | + buildreqs-overlay = ( |
| 24 | + final: prev: |
| 25 | + builtins.mapAttrs ( |
| 26 | + package: build-requirements: |
| 27 | + (builtins.getAttr package prev).overridePythonAttrs (old: { |
| 28 | + buildInputs = |
| 29 | + (old.buildInputs or []) |
| 30 | + ++ ( |
| 31 | + builtins.map |
| 32 | + (pkg: builtins.getAttr pkg final) |
| 33 | + build-requirements |
| 34 | + ); |
| 35 | + }) |
| 36 | + ) |
| 37 | + pypkgs-missing-build-requirements |
| 38 | + ); |
| 39 | + |
| 40 | + # The following modules are very slow to build or are otherwise broken. |
| 41 | + # For now, preferWheel to pull the binary dist. |
| 42 | + preferwheel-overlay = final: prev: { |
| 43 | + mypy = prev.mypy.override { |
| 44 | + # Very slow build. |
| 45 | + preferWheel = true; |
| 46 | + }; |
| 47 | + libcst = prev.libcst.override { |
| 48 | + preferWheel = true; |
| 49 | + # }).overridePythonAttrs ( old: { |
| 50 | + # # This fix is incomplete, and appears to be due to the issue here: |
| 51 | + # # https://github.com/nix-community/poetry2nix/issues/413 |
| 52 | + # # https://github.com/nix-community/poetry2nix/issues/442 |
| 53 | + # buildInputs = (old.buildInputs or []) ++ [ |
| 54 | + # pkgs.rustc |
| 55 | + # pkgs.cargo |
| 56 | + # # pkgs.rustPlatform.cargoSetupHook |
| 57 | + # final.setuptools-rust |
| 58 | + # ]; |
| 59 | + # }); |
| 60 | + }; |
| 61 | + # isort = prev.isort.override { |
| 62 | + # # Some problem building due to a malformed semantic version string. |
| 63 | + # preferWheel = true; |
| 64 | + # }; |
| 65 | + # ninja = prev.ninja.override { |
| 66 | + # # Build error. |
| 67 | + # preferWheel = true; |
| 68 | + # }; |
| 69 | + pyyaml = prev.pyyaml.override { |
| 70 | + # Build error. |
| 71 | + preferWheel = true; |
| 72 | + }; |
| 73 | + }; |
| 74 | + |
| 75 | + # Nix wraps python programs which causes PATH to change. We want to keep |
| 76 | + # PATH in case a program needs to invoke user-defined programs. |
| 77 | + dontwrap-overlay = final: prev: { |
| 78 | + fusesoc = prev.fusesoc.overridePythonAttrs { |
| 79 | + dontWrapPythonPrograms = true; |
| 80 | + }; |
| 81 | + }; |
| 82 | +in |
| 83 | + pkgs.lib.composeManyExtensions [ |
| 84 | + preferwheel-overlay |
| 85 | + buildreqs-overlay |
| 86 | + dontwrap-overlay |
| 87 | + ] |
0 commit comments