add xbuild

This commit is contained in:
Lize Live
2024-10-17 15:00:34 -07:00
parent aea1cc66cd
commit 64891836f8
4 changed files with 4570 additions and 23 deletions

24
flake.lock generated
View File

@@ -8,11 +8,11 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1725172314,
"narHash": "sha256-BtLY9lWu/pe6/ImFwuRRRqMwLacY5AZOKA2hUHUQ64k=",
"lastModified": 1728973961,
"narHash": "sha256-Jkqaw9O7WXTf5SHrK7xr9HpVU/mEPVg0Sp6s3AENC90=",
"owner": "nix-community",
"repo": "fenix",
"rev": "28b42d01f549c38bd165296fbcb4fe66d98fc24f",
"rev": "d6a9ff4d1e60c347a23bc96ccdb058d37a810541",
"type": "github"
},
"original": {
@@ -26,11 +26,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
@@ -41,11 +41,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1725194671,
"narHash": "sha256-tLGCFEFTB5TaOKkpfw3iYT9dnk4awTP/q4w+ROpMfuw=",
"lastModified": 1728979988,
"narHash": "sha256-GBJRnbFLDg0y7ridWJHAP4Nn7oss50/VNgqoXaf/RVk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b833ff01a0d694b910daca6e2ff4a3f26dee478c",
"rev": "7881fbfd2e3ed1dfa315fca889b2cfd94be39337",
"type": "github"
},
"original": {
@@ -65,11 +65,11 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1725094379,
"narHash": "sha256-TBujPMMIv8RG6BKlsBEpCln1ePmWz79xTcJOQpU2L18=",
"lastModified": 1728921748,
"narHash": "sha256-BOCZ5osPOMh2BPHnkK4sVdTGj7sn47rBn1nxjrzWe5U=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "914a1caab54e48a028b2407d0fe6fade89532f67",
"rev": "0319586ef2a2636f6d6b891690b7ebebf4337c85",
"type": "github"
},
"original": {

View File

@@ -8,18 +8,20 @@
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
fenix,
flake-utils,
}:
outputs =
{ self
, nixpkgs
, fenix
, flake-utils
,
}:
flake-utils.lib.eachDefaultSystem (
system: let
system:
let
# setup pkgs
pkgs = import nixpkgs {
inherit system;
overlays = [fenix.overlays.default];
overlays = [ fenix.overlays.default ];
config = {
android_sdk.accept_license = true;
allowUnfree = true;
@@ -41,11 +43,13 @@
targets.x86_64-pc-windows-gnu.stable.rust-std
];
androidComposition = pkgs.androidenv.composeAndroidPackages {
abiVersions = ["arm64-v8a"];
abiVersions = [ "arm64-v8a" ];
includeNDK = true;
platformVersions = ["32"];
platformVersions = [ "32" ];
};
in {
in
{
packages.default = pkgs.callPackage ./xbuild { };
devShells.default = pkgs.mkShell rec {
# build dependencies
nativeBuildInputs = with pkgs; [

4487
xbuild/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

56
xbuild/default.nix Normal file
View File

@@ -0,0 +1,56 @@
{ lib
, rustPlatform
, fetchFromGitHub
, pkg-config
, bzip2
, xz
, zstd
, stdenv
, darwin
,
}:
rustPlatform.buildRustPackage rec {
pname = "xbuild";
version = "0.2.0";
src = fetchFromGitHub {
owner = "rust-mobile";
repo = "xbuild";
rev = "ffe3e34af6a34decd98222057b140b0fafb1b07a";
hash = "sha256-60XHUkwGyTlold5/gNlbF3GIoe6nQMot9Twlt1+VSGA=";
};
cargoLock = {
lockFile = ./Cargo.lock;
};
postPatch = ''
ln -s ${./Cargo.lock} Cargo.lock
'';
nativeBuildInputs = [
pkg-config
];
buildInputs = [
bzip2
xz
zstd
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
env = {
ZSTD_SYS_USE_PKG_CONFIG = true;
};
meta = {
description = "Cross compile rust to any platform";
homepage = "https://github.com/rust-mobile/xbuild.git";
license = [ lib.licenses.mit lib.licenses.asl20 ];
maintainers = with lib.maintainers; [ ];
mainProgram = "xbuild";
};
}