nixpkgs/pkgs/by-name/ma/maturin/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

73 lines
1.7 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
darwin,
libiconv,
testers,
nix-update-script,
maturin,
python3,
}:
rustPlatform.buildRustPackage rec {
pname = "maturin";
version = "1.7.1";
src = fetchFromGitHub {
owner = "PyO3";
repo = "maturin";
rev = "v${version}";
hash = "sha256-kFhY2ixZZrSA/YxLCQDLPjLqNWQI3zl5V1MLTPqQH60=";
};
cargoHash = "sha256-ik6kFS66umiHf0M1fE+6++zpZF4gJrN9LQ2l+vi9SSY=";
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Security
libiconv
];
# Requires network access, fails in sandbox.
doCheck = false;
passthru = {
tests = {
version = testers.testVersion { package = maturin; };
pyo3 = python3.pkgs.callPackage ./pyo3-test {
format = "pyproject";
buildAndTestSubdir = "examples/word-count";
preConfigure = "";
nativeBuildInputs = with rustPlatform; [
cargoSetupHook
maturinBuildHook
];
};
};
updateScript = nix-update-script { };
};
meta = {
description = "Build and publish Rust crates Python packages";
longDescription = ''
Build and publish Rust crates with PyO3, rust-cpython, and
cffi bindings as well as Rust binaries as Python packages.
This project is meant as a zero-configuration replacement for
setuptools-rust and Milksnake. It supports building wheels for
Python and can upload them to PyPI.
'';
homepage = "https://github.com/PyO3/maturin";
changelog = "https://github.com/PyO3/maturin/blob/v${version}/Changelog.md";
license = with lib.licenses; [
asl20 # or
mit
];
maintainers = with lib.maintainers; [ getchoo ];
mainProgram = "maturin";
};
}