diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/rure')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/rure/Cargo.lock | 61 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/libraries/rure/default.nix | 46 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/libraries/rure/pin.json | 5 | ||||
-rwxr-xr-x | nixpkgs/pkgs/development/libraries/rure/update.sh | 51 |
4 files changed, 163 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/rure/Cargo.lock b/nixpkgs/pkgs/development/libraries/rure/Cargo.lock new file mode 100644 index 000000000000..1dd2aeb38b4e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/rure/Cargo.lock @@ -0,0 +1,61 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rure" +version = "0.2.2" +dependencies = [ + "libc", + "regex", +] diff --git a/nixpkgs/pkgs/development/libraries/rure/default.nix b/nixpkgs/pkgs/development/libraries/rure/default.nix new file mode 100644 index 000000000000..1771abd3367a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/rure/default.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, rustPlatform +, fetchCrate +, fixDarwinDylibNames +}: + +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" + ''; + + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ + fixDarwinDylibNames + ]; + + 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/nixpkgs/pkgs/development/libraries/rure/pin.json b/nixpkgs/pkgs/development/libraries/rure/pin.json new file mode 100644 index 000000000000..7e6b1101702e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/rure/pin.json @@ -0,0 +1,5 @@ +{ + "pname": "rure", + "version": "0.2.2", + "sha256": "0n2c9b8arfgcq1l7gr8dfcmdvdbggvfd0msy6sbx3bln74wwbr06" +} diff --git a/nixpkgs/pkgs/development/libraries/rure/update.sh b/nixpkgs/pkgs/development/libraries/rure/update.sh new file mode 100755 index 000000000000..6e85d7cf03a7 --- /dev/null +++ b/nixpkgs/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 <<EOF +{ + "pname": "$crate", + "version": "$version", + "sha256": "$(printf '%s' "$prefetch" | head -n1)" +} +EOF + +echo "Generating updated Cargo.lock" >&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 |