diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix index 75377190cc7f..e996e6e5e584 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix @@ -301,7 +301,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // { mDNSResponder = applePackage "mDNSResponder" "osx-10.12.6" "sha256-ddZr6tropkpdMJhq/kUlm3OwO8b0yxtkrMpwec8R4FY=" {}; objc4 = applePackage "objc4" "osx-10.12.6" "sha256-ZsxRpdsfv3Dxs7yBBCkjbKXKR6aXwkEpxc1XYXz7ueM=" {}; ppp = applePackage "ppp" "osx-10.12.6" "sha256-M1zoEjjeKIDUEP6ACbpUJk3OXjobw4g/qzUmxGdX1J0=" {}; - removefile = applePackage "removefile" "osx-10.12.6" "sha256-UpNk27kGXnZss1ZXWVJU9jLz/NW63ZAZEDLhyCYoi9M=" {}; + removefile = callPackage ./removefile/package.nix { }; xnu = if isSdk10_12 then applePackage "xnu" "osx-10.12.6" "sha256-C8TPQlUT3RbzAy8YnZPNtr70hpaVG9Llv0h42s3NENI=" {} else macosPackages_11_0_1.xnu; diff --git a/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix b/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix deleted file mode 100644 index 611f445e1ec9..000000000000 --- a/pkgs/os-specific/darwin/apple-source-releases/removefile/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ appleDerivation', stdenvNoCC }: - -appleDerivation' stdenvNoCC { - installPhase = '' - mkdir -p $out/include/ - cp removefile.h checkint.h $out/include/ - ''; - - appleHeaders = '' - checkint.h - removefile.h - ''; -} diff --git a/pkgs/os-specific/darwin/apple-source-releases/removefile/meson.build.in b/pkgs/os-specific/darwin/apple-source-releases/removefile/meson.build.in new file mode 100644 index 000000000000..672a15a40b8e --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/removefile/meson.build.in @@ -0,0 +1,43 @@ +# Build settings based on the upstream Xcode project. +# See: https://github.com/apple-oss-distributions/removefile/blob/main/removefile.xcodeproj/project.pbxproj + +# Project settings +project('removefile', 'c', version : '@version@') + + +# Dependencies +cc = meson.get_compiler('c') + + +# Libraries +library( + 'removefile', + c_args : [ + '-D__DARWIN_NOW_CANCELABLE=1', + # Define these flags for the 10.12 SDK assuming that users on older systems can’t encounter dataless files. + # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/stat.h#L520 + '-DSF_DATALESS=0x40000000', + # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/resource.h#L598 + '-DIOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES=3', + # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/resource.h#L640 + '-DIOPOL_MATERIALIZE_DATALESS_FILES_OFF=1', + # https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/attr.h#L562 + # '-DATTR_CMNEXT_LINKID=0x00000010', + ], + install : true, + sources : [ + 'removefile.c', + 'removefile_random.c', + 'removefile_rename_unlink.c', + 'removefile_sunlink.c', + 'removefile_tree_walker.c', + ], +) +install_headers( + 'checkint.h', + 'removefile.h', +) +install_man( + 'checkint.3', + 'removefile.3', +) diff --git a/pkgs/os-specific/darwin/apple-source-releases/removefile/package.nix b/pkgs/os-specific/darwin/apple-source-releases/removefile/package.nix new file mode 100644 index 000000000000..9eee8232d89f --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/removefile/package.nix @@ -0,0 +1,49 @@ +{ + apple-sdk, + apple-sdk_10_13, + apple-sdk_11, + mkAppleDerivation, + stdenvNoCC, +}: + +let + # The 10.12 SDK doesn’t have the files needed in the same places or possibly at all. + # Just use the 11.x SDK to make things easier. + xnu = apple-sdk_11.sourceRelease "xnu"; + + privateHeaders = stdenvNoCC.mkDerivation { + name = "removefile-deps-private-headers"; + + buildCommand = '' + mkdir -p "$out/include/apfs" + # APFS group is 'J' per https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/vfs/vfs_fsevents.c#L1054 + cat < "$out/include/apfs/apfs_fsctl.h" + #pragma once + #include + #include + struct xdstream_obj_id { + char* xdi_name; + uint64_t xdi_xdtream_obj_id; + }; + #define APFS_CLEAR_PURGEABLE 0 + #define APFSIOC_MARK_PURGEABLE _IOWR('J', 68, uint64_t) + #define APFSIOC_XDSTREAM_OBJ_ID _IOR('J', 35, struct xdstream_obj_id) + EOF + ''; + }; +in +mkAppleDerivation { + releaseName = "removefile"; + + outputs = [ + "out" + "dev" + "man" + ]; + + xcodeHash = "sha256-wDm2LECjateIRDQyjJtcdbxHKVfN3Y8JXVd70d37Jy4="; + + env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include"; + + meta.description = "Darwin file removing library"; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/versions.json b/pkgs/os-specific/darwin/apple-source-releases/versions.json index f8acca90a704..e1597744be46 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/versions.json +++ b/pkgs/os-specific/darwin/apple-source-releases/versions.json @@ -58,5 +58,9 @@ "network_cmds": { "hash": "sha256-PChAbC/4cHa0lbojElR2PHOUo+cDvsoNdiorle0IXss=", "version": "606.40.2" + }, + "removefile": { + "hash": "sha256-UpNk27kGXnZss1ZXWVJU9jLz/NW63ZAZEDLhyCYoi9M=", + "version": "45" } }