summary refs log tree commit diff
path: root/pkgs/os-specific/darwin/apple-source-releases/diskdev_cmds/default.nix
blob: 6d3bd103811d8190e91c572bef4d3949cf25a3d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ stdenv, appleDerivation, xcbuildHook
, Libc, xnu, libutil }:

appleDerivation {
  nativeBuildInputs = [ xcbuildHook ];
  buildInputs = [ libutil ];

  NIX_CFLAGS_COMPILE = "-I.";
  NIX_LDFLAGS = "-lutil";
  patchPhase = ''
    # ugly hacks for missing headers
    # most are bsd related - probably should make this a drv
    unpackFile ${Libc.src}
    unpackFile ${xnu.src}
    mkdir System sys machine i386
    cp xnu-*/bsd/sys/disklabel.h sys
    cp xnu-*/bsd/machine/disklabel.h machine
    cp xnu-*/bsd/i386/disklabel.h i386
    cp -r xnu-*/bsd/sys System
    cp -r Libc-*/uuid System
    substituteInPlace diskdev_cmds.xcodeproj/project.pbxproj \
      --replace 'DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";' ""
  '';
  installPhase = ''
    install -D Products/Release/libdisk.a $out/lib/libdisk.a
    rm Products/Release/libdisk.a
    for f in Products/Release/*; do
      if [ -f $f ]; then
        install -D $f $out/bin/$(basename $f)
      fi
    done
  '';

  meta = {
    platforms = stdenv.lib.platforms.darwin;
    maintainers = with stdenv.lib.maintainers; [ matthewbauer ];
  };
}