Abstract out the apple sdk bits into a shared library

This commit is contained in:
Jeremy Wall 2023-03-18 18:34:05 -04:00
parent 8e075d681c
commit 1d924fb702
3 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
{ pkgs, rust-wasm }:
with pkgs;
mkShell {
buildInputs = (if stdenv.isDarwin then [ pkgs.darwin.apple_sdk.frameworks.Security ] else [ ]) ++ (with pkgs; [wasm-bindgen-cli wasm-pack llvm clang rust-wasm]);
buildInputs = (lib.darwin-sdk pkgs) ++ (with pkgs; [wasm-bindgen-cli wasm-pack llvm clang rust-wasm]);
}

View File

@ -1,3 +1,6 @@
let
lib = import ../lib/lib.nix;
in
{pkgs ? (import <nixpkgs>) {},
# Because it's a workspace we need the other crates available as source
root,
@ -12,11 +15,7 @@ with pkgs;
inherit version;
buildInputs = [ rust-wasm libclang ];
# However the crate we are building has it's root in specific crate.
nativeBuildInputs = (if stdenv.isDarwin then (with pkgs.darwin.apple_sdk.frameworks; [
xcbuild
Security
fixDarwinDylibNames
]) else [ ]) ++ [llvm clang rust-bindgen];
nativeBuildInputs = (lib.darwin-sdk pkgs) ++ [llvm clang rust-bindgen];
src = root;
cargoBuildOptions = opts: opts ++ ["-p" "${pname}" ];
postPatch = ''

7
nix/lib/lib.nix Normal file
View File

@ -0,0 +1,7 @@
{
darwin-sdk = pkgs: with pkgs; (if stdenv.isDarwin then (with darwin.apple_sdk.frameworks; [
xcbuild
Security
fixDarwinDylibNames
]) else [ ]);
}