Merge pull request #232699 from nickgerace/reindeer
reindeer: init at unstable-2023-05-18
This commit is contained in:
commit
02f08ed58a
@ -11287,6 +11287,11 @@
|
||||
github = "NickCao";
|
||||
githubId = 15247171;
|
||||
};
|
||||
nickgerace = {
|
||||
name = "Nick Gerace";
|
||||
github = "nickgerace";
|
||||
githubId = 39320683;
|
||||
};
|
||||
nickhu = {
|
||||
email = "me@nickhu.co.uk";
|
||||
github = "NickHu";
|
||||
|
1963
pkgs/development/tools/reindeer/Cargo.lock
generated
Normal file
1963
pkgs/development/tools/reindeer/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
48
pkgs/development/tools/reindeer/default.nix
Normal file
48
pkgs/development/tools/reindeer/default.nix
Normal file
@ -0,0 +1,48 @@
|
||||
{ lib
|
||||
, rustPlatform
|
||||
, fetchFromGitHub
|
||||
, pkg-config
|
||||
, openssl
|
||||
, stdenv
|
||||
, libiconv
|
||||
, darwin
|
||||
, nix-update-script
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "reindeer";
|
||||
version = "unstable-2023-05-18";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "facebookincubator";
|
||||
repo = pname;
|
||||
rev = "2d6d37dcddaa840b6cd99951176c972f4c3afddd";
|
||||
sha256 = "sha256-31Kf6cVqAVFprTHEJp06E0p0y5YwdowhmPti8JBJw3g=";
|
||||
};
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
ln -s ${./Cargo.lock} Cargo.lock
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs =
|
||||
[ openssl ] ++ lib.optionals stdenv.isDarwin [
|
||||
libiconv
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
darwin.apple_sdk.frameworks.CoreServices
|
||||
];
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Reindeer is a tool which takes Rust Cargo dependencies and generates Buck build rules";
|
||||
homepage = "https://github.com/facebookincubator/reindeer";
|
||||
license = with licenses; [ mit ];
|
||||
maintainers = with maintainers; [ nickgerace ];
|
||||
};
|
||||
}
|
||||
|
37
pkgs/development/tools/reindeer/update.sh
Executable file
37
pkgs/development/tools/reindeer/update.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -I nixpkgs=./. -i bash -p curl jq nix-prefetch common-updater-scripts mktemp nix coreutils
|
||||
|
||||
# First, check that we only update once per day since the version tag is dependent on the date.
|
||||
NEW_VERSION="unstable-$(date +%F)"
|
||||
CURRENT_VERSION=$(nix-instantiate --eval -E "with import ./. {}; reindeer.version" | tr -d '"')
|
||||
if [[ "$NEW_VERSION" == "$CURRENT_VERSION" ]]; then
|
||||
echo "skipping reindeer update within same day (version: \"$CURRENT_VERSION\")"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Second, let's check if there's a new commit to main.
|
||||
NEW_REV=$(curl https://api.github.com/repos/facebookincubator/reindeer/branches/main | jq '.commit.sha')
|
||||
CURRENT_REV=$(nix-instantiate --eval -E "with import ./. {}; reindeer.src.rev")
|
||||
if [[ "$NEW_REV" == "$CURRENT_REV" ]]; then
|
||||
echo "reindeer is up-to-date (rev: $CURRENT_REV)"
|
||||
exit 0
|
||||
fi
|
||||
echo "updating reindeer (new: $NEW_REV) (old: $CURRENT_REV)"
|
||||
|
||||
# Generate the new lockfile in a temporary directory.
|
||||
pushd $(mktemp -d)
|
||||
git clone https://github.com/facebookincubator/reindeer.git --depth=1
|
||||
pushd reindeer
|
||||
cargo generate-lockfile
|
||||
LOCKFILE=$(realpath ./Cargo.lock)
|
||||
popd
|
||||
popd
|
||||
cp $LOCKFILE pkgs/development/tools/reindeer/
|
||||
|
||||
# Get the new sha256 value.
|
||||
TRIMMED_REV=$(echo $NEW_REV | tr -d '"')
|
||||
HASH_RAW=$(nix-prefetch-url https://github.com/facebookincubator/reindeer/archive/${TRIMMED_REV}.tar.gz --unpack --type sha256)
|
||||
HASH_SRI=$(nix hash to-sri --type sha256 ${HASH_RAW})
|
||||
|
||||
# Update the file accordingly.
|
||||
update-source-version reindeer "$NEW_VERSION" ${HASH_SRI} --rev=${TRIMMED_REV}
|
@ -40485,4 +40485,6 @@ with pkgs;
|
||||
zf = callPackage ../tools/misc/zf { };
|
||||
|
||||
isolate = callPackage ../tools/security/isolate { };
|
||||
|
||||
reindeer = callPackage ../development/tools/reindeer { };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user