diff --git a/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix b/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix index 1a0589ce740..e1f6dfa3a8b 100644 --- a/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix +++ b/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix @@ -241,4 +241,7 @@ self: super: { # https://github.com/sjakobi/bsb-http-chunked/issues/38 bsb-http-chunked = dontCheck super.bsb-http-chunked; + + # need bytestring >= 0.11 which is only bundled with GHC >= 9.2 + regex-rure = doDistribute (markUnbroken super.regex-rure); } diff --git a/pkgs/development/haskell-modules/hackage-packages.nix b/pkgs/development/haskell-modules/hackage-packages.nix index d25b88206b5..ca8afb77c36 100644 --- a/pkgs/development/haskell-modules/hackage-packages.nix +++ b/pkgs/development/haskell-modules/hackage-packages.nix @@ -231650,7 +231650,7 @@ self: { license = lib.licenses.agpl3Only; hydraPlatforms = lib.platforms.none; broken = true; - }) {rure = null;}; + }) {inherit (pkgs) rure;}; "regex-tdfa" = callPackage ({ mkDerivation, array, base, bytestring, containers, directory diff --git a/pkgs/development/libraries/rure/Cargo.lock b/pkgs/development/libraries/rure/Cargo.lock new file mode 100644 index 00000000000..ce760ae2331 --- /dev/null +++ b/pkgs/development/libraries/rure/Cargo.lock @@ -0,0 +1,49 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "libc" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "rure" +version = "0.2.1" +dependencies = [ + "libc", + "regex", +] diff --git a/pkgs/development/libraries/rure/default.nix b/pkgs/development/libraries/rure/default.nix new file mode 100644 index 00000000000..aef8b9c8f3e --- /dev/null +++ b/pkgs/development/libraries/rure/default.nix @@ -0,0 +1,41 @@ +{ lib +, stdenv +, rustPlatform +, fetchCrate +}: + +let + pin = lib.importJSON ./pin.json; +in + +rustPlatform.buildRustPackage { + inherit (pin) pname version; + + src = fetchCrate pin; + + # upstream doesn't ship a Cargo.lock, is generated by the update script + postPatch = '' + cp ${./Cargo.lock} Cargo.lock + ''; + + cargoLock.lockFile = ./Cargo.lock; + + outputs = [ "out" "dev" ]; + + # Headers are not handled by cargo nor buildRustPackage + postInstall = '' + install -Dm644 include/rure.h -t "$dev/include" + ''; + + passthru.updateScript = ./update.sh; + + meta = { + description = "A C API for Rust's regular expression library"; + homepage = "https://crates.io/crates/rure"; + license = [ + lib.licenses.mit + lib.licenses.asl20 + ]; + maintainers = [ lib.maintainers.sternenseemann ]; + }; +} diff --git a/pkgs/development/libraries/rure/pin.json b/pkgs/development/libraries/rure/pin.json new file mode 100644 index 00000000000..234631d07c6 --- /dev/null +++ b/pkgs/development/libraries/rure/pin.json @@ -0,0 +1,5 @@ +{ + "pname": "rure", + "version": "0.2.1", + "sha256": "18sd1dfagf2338mp32kfjbqpc3n0agm61p044jl7yhy299ws21r8" +} diff --git a/pkgs/development/libraries/rure/update.sh b/pkgs/development/libraries/rure/update.sh new file mode 100755 index 00000000000..6e85d7cf03a --- /dev/null +++ b/pkgs/development/libraries/rure/update.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env nix-shell +#! nix-shell -p nix jq curl cargo rsync +#! nix-shell -i bash + +set -eu + +cd "$(dirname "$0")" + +crate=rure + +echo "Getting latest version from crates.io API" >&2 + +curlOpts=( + -H "Accept: application/json" + -H "User-Agent: $crate update script (https://github.com/nixos/nixpkgs/)" +) + +version="$(curl "${curlOpts[@]}" "https://crates.io/api/v1/crates/$crate" \ + | jq -r .crate.max_stable_version)" + +echo "Prefetching latest tarball from crates.io" >&2 + +url="https://crates.io/api/v1/crates/$crate/$version/download" +prefetch="$(nix-prefetch-url --print-path --type sha256 --unpack "$url")" + +cat > pin.json <&2 + +tmp="$(mktemp -d)" + +cleanup() { + echo "Removing $tmp" >&2 + rm -rf "$tmp" +} + +trap cleanup EXIT + +rsync -a --chmod=ugo=rwX "$(printf '%s' "$prefetch" | tail -n1)/" "$tmp" + +pushd "$tmp" +cargo update +popd + +cp "$tmp/Cargo.lock" ./Cargo.lock diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e3dde9fea9d..ef154010010 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19696,6 +19696,8 @@ with pkgs; rubberband = callPackage ../development/libraries/rubberband { }; + rure = callPackage ../development/libraries/rure { }; + rustc-demangle = callPackage ../development/libraries/rustc-demangle { }; s2geometry = callPackage ../development/libraries/s2geometry { };