nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 apple-sdk,
3 mkAppleDerivation,
4 stdenvNoCC,
5}:
6
7let
8 xnu = apple-sdk.sourceRelease "xnu";
9
10 privateHeaders = stdenvNoCC.mkDerivation {
11 name = "removefile-deps-private-headers";
12
13 buildCommand = ''
14 mkdir -p "$out/include/apfs"
15 # APFS group is 'J' per https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/vfs/vfs_fsevents.c#L1054
16 cat <<EOF > "$out/include/apfs/apfs_fsctl.h"
17 #pragma once
18 #include <stdint.h>
19 #include <sys/ioccom.h>
20 struct xdstream_obj_id {
21 char* xdi_name;
22 uint64_t xdi_xdtream_obj_id;
23 };
24 #define APFS_CLEAR_PURGEABLE 0
25 #define APFSIOC_MARK_PURGEABLE _IOWR('J', 68, uint64_t)
26 #define APFSIOC_XDSTREAM_OBJ_ID _IOR('J', 35, struct xdstream_obj_id)
27 EOF
28 '';
29 };
30in
31mkAppleDerivation {
32 releaseName = "removefile";
33
34 outputs = [
35 "out"
36 "dev"
37 "man"
38 ];
39
40 xcodeHash = "sha256-pE92mVI0KTHOVKBA4T5R1rHy5//uipOimas7DaTVe0U=";
41
42 postPatch = ''
43 # Disable experimental bounds safety stuff that’s not available in LLVM 16.
44 substituteInPlace removefile.h \
45 --replace-fail '__ptrcheck_abi_assume_single()' "" \
46 --replace-fail '__unsafe_indexable' ""
47 '';
48
49 env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
50
51 meta.description = "Darwin file removing library";
52}