Exclude crown from the root Cargo workspace (#34173)

* Exclude crown from workspace

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Update shell.nix and remove filterlock

Signed-off-by: Delan Azabani <dazabani@igalia.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
Samson 2024-11-08 11:08:49 +01:00 committed by GitHub
parent ac5c67849e
commit 39ef61c324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 693 additions and 395 deletions

View file

@ -92,52 +92,17 @@ stdenv.mkDerivation (androidEnvironment // {
# See https://github.com/servo/mozjs/issues/375
pkgs_gnumake_4_3.gnumake
# crown needs to be in our Cargo workspace so we can test it with `mach test`. This means its
# dependency tree is listed in the main Cargo.lock, making it awkward to build with Nix because
# all of Servos dependencies get pulled into the Nix store too, wasting over 1GB of disk space.
# Filtering the lockfile to only the parts needed by crown saves space and builds faster.
(let
# Build and run filterlock over the main Cargo.lock.
filteredLockFile = (clangStdenv.mkDerivation {
name = "lock";
buildInputs = [ rustToolchain ];
nativeBuildInputs = [ rustPlatform.cargoSetupHook ];
src = ../support/filterlock;
cargoDeps = rustPlatform.importCargoLock {
lockFile = ../support/filterlock/Cargo.lock;
};
buildPhase = ''
> $out cargo run --offline -- ${../Cargo.lock} crown
'';
dontInstall = true;
});
in (rustPlatform.buildRustPackage {
(rustPlatform.buildRustPackage {
name = "crown";
src = ../support/crown;
doCheck = false;
cargoLock = {
lockFileContents = builtins.readFile filteredLockFile;
# Needed when not filtering (filteredLockFile = ../Cargo.lock), else well get errors like
# “error: No hash was found while vendoring the git dependency blurmac-0.1.0.”
# allowBuiltinFetchGit = true;
# crown is not in our Cargo workspace, so this only pulls crown and crowns dependencies
# into the Nix store, not Servo and Servos dependencies.
lockFile = ../support/crown/Cargo.lock;
};
# Copy the filtered lockfile, making it writable by cargo --offline.
postPatch = ''
install -m 644 ${filteredLockFile} Cargo.lock
'';
# Reformat the filtered lockfile, so that cargo --frozen wont complain
# about the lockfile being dirty.
# TODO maybe this can be avoided by using toml_edit in filterlock?
preConfigure = ''
cargo update --offline
'';
RUSTC_BOOTSTRAP = "crown";
}))
})
] ++ (lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.AppKit
]) ++ (lib.optionals buildAndroid [