From 8ec7216e9a4e134a5f6b8a88a83e8742bd635cca Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 19 Jun 2021 22:25:07 +0800 Subject: [PATCH] update cargo-xbuild --- default.nix | 2 +- nix/cargo-xbuild.nix | 22 ++++++++++++++++++++++ xbuild_writable_lockfile.diff | 27 --------------------------- 3 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 nix/cargo-xbuild.nix delete mode 100644 xbuild_writable_lockfile.diff diff --git a/default.nix b/default.nix index 33eeea9..3098409 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,7 @@ let pkgs = import { overlays = [ (import ./nix/mozilla-overlay.nix) ]; }; rustPlatform = (import ./nix/rust-platform.nix { inherit pkgs; }); - cargo-xbuild = (pkgs.cargo-xbuild.overrideAttrs(oa: { patches = oa.patches ++ [ ./xbuild_writable_lockfile.diff ]; } )); + cargo-xbuild = pkgs.callPackage ./nix/cargo-xbuild.nix {}; cargoSha256Experiments = "0d2v6n6a73vhxm6yq60mvv9pxxxah88kzryb0w32i0ddhfj4rrs7"; cargoSha256SZL = "0ghj5bbix8417wdismwmxkykvdknikwkvg7sjcjmrywnqk4ka6lg"; build-crate = name: crate: features: cargoSha256: diff --git a/nix/cargo-xbuild.nix b/nix/cargo-xbuild.nix new file mode 100644 index 0000000..facc8cb --- /dev/null +++ b/nix/cargo-xbuild.nix @@ -0,0 +1,22 @@ +{ lib, fetchFromGitHub, rustPlatform }: + +rustPlatform.buildRustPackage rec { + pname = "cargo-xbuild"; + version = "0.6.5"; + + src = fetchFromGitHub { + owner = "rust-osdev"; + repo = pname; + rev = "v${version}"; + sha256 = "18djvygq9v8rmfchvi2hfj0i6fhn36m716vqndqnj56fiqviwxvf"; + }; + + cargoSha256 = "13sj9j9kl6js75h9xq0yidxy63vixxm9q3f8jil6ymarml5wkhx8"; + + meta = with lib; { + description = "Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc"; + homepage = "https://github.com/rust-osdev/cargo-xbuild"; + license = with licenses; [ mit asl20 ]; + maintainers = with maintainers; [ johntitor xrelkd ]; + }; +} diff --git a/xbuild_writable_lockfile.diff b/xbuild_writable_lockfile.diff deleted file mode 100644 index 8e8f6f9..0000000 --- a/xbuild_writable_lockfile.diff +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/src/sysroot.rs b/src/sysroot.rs -index 1f3c8d1..422d3d0 100644 ---- a/src/sysroot.rs -+++ b/src/sysroot.rs -@@ -85,10 +85,20 @@ fn build_crate( - } - - util::write(&td.join("Cargo.toml"), &stoml)?; -- fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(|| -+ let dst_file = td.join("Cargo.lock"); -+ fs::copy(lockfile, &dst_file).chain_err(|| - format!("failed to copy Cargo.lock from `{}` to `{}`", -- lockfile.display(), &td.join("Cargo.lock").display()) -+ lockfile.display(), &dst_file.display()) - )?; -+ let mut perms = fs::metadata(&dst_file).chain_err(|| -+ format!("failed to retrieve permissions for `{}`", -+ dst_file.display()) -+ )?.permissions(); -+ perms.set_readonly(false); -+ fs::set_permissions(&dst_file, perms).chain_err(|| -+ format!("failed to update permissions for `{}`", -+ dst_file.display()) -+ ); - util::mkdir(&td.join("src"))?; - util::write(&td.join("src/lib.rs"), "")?; -