refactor(tvix): assemble cragoDeps outputHashes from Cargo.nix
We already have these hashes accessible in the Cargo.nix file created by cargo2nix, so there's no need to also manually maintain them here. It removes one potential footgun I ran into while updating wu-manber to a different rev, without updating it here. Change-Id: I93932ac8ba55f83746ee38571b7740af2d49bbdf Reviewed-on: https://cl.tvl.fyi/c/depot/+/9090 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
bba7bbf820
commit
778bd6894b
1 changed files with 21 additions and 12 deletions
|
@ -1,21 +1,10 @@
|
|||
# Nix helpers for projects under //tvix
|
||||
{ pkgs, depot, ... }:
|
||||
{ pkgs, lib, depot, ... }:
|
||||
|
||||
let
|
||||
# crate override for crates that need protobuf
|
||||
protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ];
|
||||
|
||||
# Cargo dependencies to be used with nixpkgs rustPlatform functions.
|
||||
cargoDeps = pkgs.rustPlatform.importCargoLock {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"test-generator-0.3.0" = "08brp3qqa55hijc7xby3lam2cc84hvx1zzfqv6lj7smlczh8k32y";
|
||||
"tonic-mock-0.1.0" = "0lwa03hpp0mxa6aa1zv5w68k61y4hccfm0q2ykyq392fwal8vb50";
|
||||
"wu-manber-0.1.0" = "1zhk83lbq99xzyjwphv2qrb8f8qgfqwa5bbbvyzm0z0bljsjv0pd";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
# Load the crate2nix crate tree.
|
||||
crates = import ./Cargo.nix {
|
||||
inherit pkgs;
|
||||
|
@ -42,6 +31,26 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# Cargo dependencies to be used with nixpkgs rustPlatform functions.
|
||||
cargoDeps = pkgs.rustPlatform.importCargoLock {
|
||||
lockFile = ./Cargo.lock;
|
||||
# Extract the hashes from `crates` / Cargo.nix, we already get them from cargo2nix.
|
||||
# This returns an attribute set containing "${crateName}-${version}" as key,
|
||||
# and the outputHash as value.
|
||||
outputHashes = builtins.listToAttrs
|
||||
(map
|
||||
(crateName:
|
||||
(lib.nameValuePair "${crateName}-${crates.internal.crates.${crateName}.version}" crates.internal.crates.${crateName}.src.outputHash)
|
||||
) [
|
||||
"test-generator"
|
||||
"tonic-mock"
|
||||
"wu-manber"
|
||||
]);
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit crates;
|
||||
|
||||
# Run crate2nix generate in the current working directory, then
|
||||
# format the generated file with depotfmt.
|
||||
crate2nixGenerate = pkgs.writeShellScriptBin "crate2nix-generate" ''
|
||||
|
|
Loading…
Reference in a new issue