Skip to content

Commit 64f08fc

Browse files
committed
feat: nix build on darwin
1 parent 6039cb0 commit 64f08fc

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

flake.nix

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,21 @@
3838
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
3939
src = craneLib.cleanCargoSource ./.;
4040

41-
commonArgs = {
41+
cargoVendorDir = craneLib.vendorCargoDeps {
4242
inherit src;
43+
44+
overrideVendorCargoPackage = p: drv:
45+
if p.name == "libusb1-sys" && p.version == "0.7.0" then
46+
drv.overrideAttrs
47+
(_old: {
48+
patches = [ ./nix/patches/libusb1-sys.patch ];
49+
})
50+
else
51+
drv;
52+
};
53+
54+
commonArgs = {
55+
inherit src cargoVendorDir;
4356
strictDeps = true;
4457

4558
buildInputs = with pkgs; [

nix/patches/libusb1-sys.patch

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From ea6bb37b6e281586244b894dd16bae980475b278 Mon Sep 17 00:00:00 2001
2+
From: Sirius902 <10891979+Sirius902@users.noreply.github.com>
3+
Date: Thu, 30 Jan 2025 17:07:25 -0800
4+
Subject: [PATCH] Hardcode output of sw_vers
5+
6+
---
7+
build.rs | 6 +-----
8+
1 file changed, 1 insertion(+), 5 deletions(-)
9+
10+
diff --git a/build.rs b/build.rs
11+
index 3d05d43..fed5be8 100644
12+
--- a/build.rs
13+
+++ b/build.rs
14+
@@ -24,11 +24,7 @@ fn get_macos_major_version() -> Option<usize> {
15+
return None;
16+
}
17+
18+
- let output = std::process::Command::new("sw_vers")
19+
- .args(["-productVersion"])
20+
- .output()
21+
- .unwrap();
22+
- let version = std::str::from_utf8(&output.stdout).unwrap().trim_end();
23+
+ let version = "11.0";
24+
let components: Vec<&str> = version.split('.').collect();
25+
let major: usize = components[0].parse().unwrap();
26+
Some(major)
27+
--
28+
2.48.1
29+

0 commit comments

Comments
 (0)