about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/virtualization/bochs/default.nix
blob: 3a8e9dc0bee7f082374ed77b7284ce23291c4636 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{ lib, stdenv, fetchurl
, pkg-config, libtool
, gtk2, libGLU, libGL, readline, libX11, libXpm
, docbook_xml_dtd_45, docbook_xsl
, sdlSupport ? true, SDL2 ? null
, termSupport ? true, ncurses ? null
, wxSupport ? true, wxGTK ? null
, wgetSupport ? false, wget ? null
, curlSupport ? false, curl ? null
}:

assert sdlSupport -> (SDL2 != null);
assert termSupport -> (ncurses != null);
assert wxSupport -> (gtk2 != null && wxGTK != null);
assert wgetSupport -> (wget != null);
assert curlSupport -> (curl != null);

with lib;
stdenv.mkDerivation rec {

  pname = "bochs";
  version = "2.6.11";

  src = fetchurl {
    url = "mirror://sourceforge/project/bochs/bochs/${version}/${pname}-${version}.tar.gz";
    sha256 = "0ql8q6y1k356li1g9gbvl21448mlxphxxi6kjb2b3pxvzd0pp2b3";
  };

  patches = [
    ./bochs-2.6.11-glibc-2.26.patch
    ./fix-build-smp.patch
    ./bochs_fix_narrowing_conv_warning.patch
  ];

  buildInputs =
  [ pkg-config libtool gtk2 libGLU libGL readline libX11 libXpm docbook_xml_dtd_45 docbook_xsl ]
  ++ optionals termSupport [ ncurses ]
  ++ optionals sdlSupport [ SDL2 ]
  ++ optionals wxSupport [ wxGTK ]
  ++ optionals wgetSupport [ wget ]
  ++ optionals curlSupport [ curl ];

  configureFlags = [
    "--with-x=yes"
    "--with-x11=yes"

    "--with-rfb=no"
    "--with-vncsrv=no"
    "--with-svga=no" # it doesn't compile on NixOS

    # These will always be "yes" on NixOS
    "--enable-ltdl-install=yes"
    "--enable-readline=yes"
    "--enable-all-optimizations=yes"
    "--enable-logging=yes"
    "--enable-xpm=yes"

    # ... whereas these, always "no"!
    "--enable-cpp=no"
    "--enable-instrumentation=no"

    "--enable-docbook=no" # Broken - it requires docbook2html

    # Dangerous options - they are marked as "incomplete/experimental" on Bochs documentation
    "--enable-3dnow=no"
    "--enable-monitor-mwait=no"
    "--enable-raw-serial=no" ]
    # Boolean flags
    ++ optionals termSupport [ "--with-term" ]
    ++ optionals sdlSupport [ "--with-sdl2" ]
    ++ optionals wxSupport [ "--with-wx" ]
    # These are completely configurable, and they don't depend of external tools
    ++ [ "--enable-cpu-level=6" # from 3 to 6
         "--enable-largefile"
         "--enable-idle-hack"
         "--enable-plugins=no" # Plugins are a bit buggy in Bochs
         "--enable-a20-pin"
         "--enable-x86-64"
         "--enable-smp"
         "--enable-large-ramfile"
         "--enable-repeat-speedups"
         "--enable-handlers-chaining"
         "--enable-trace-linking"
         "--enable-configurable-msrs"
         "--enable-show-ips"
         "--enable-debugger" #conflicts with gdb-stub option
         "--enable-disasm"
         "--enable-debugger-gui"
         "--enable-gdb-stub=no" # conflicts with debugger option
         "--enable-iodebug"
         "--enable-fpu"
         "--enable-svm"
         "--enable-avx"
         "--enable-evex"
         "--enable-x86-debugger"
         "--enable-pci"
         "--enable-usb"
         "--enable-usb-ohci"
         "--enable-usb-ehci"
         "--enable-usb-xhci"
         "--enable-ne2000"
         "--enable-pnic"
         "--enable-e1000"
         "--enable-clgd54xx"
         "--enable-voodoo"
         "--enable-cdrom"
         "--enable-sb16"
         "--enable-es1370"
         "--enable-busmouse" ];

  NIX_CFLAGS_COMPILE="-I${gtk2.dev}/include/gtk-2.0/ -I${libtool}/include/";
  NIX_LDFLAGS="-L${libtool.lib}/lib";

  hardeningDisable = [ "format" ];

  enableParallelBuilding = true;

  meta = {
    description = "An open-source IA-32 (x86) PC emulator";
    longDescription = ''
      Bochs is an open-source (LGPL), highly portable IA-32 PC emulator, written
      in C++, that runs on most popular platforms. It includes emulation of the
      Intel x86 CPU, common I/O devices, and a custom BIOS.
    '';
    homepage = "http://bochs.sourceforge.net/";
    license = licenses.lgpl2Plus;
    maintainers = with maintainers; [ AndersonTorres ];
    platforms = platforms.unix;
  };
}
# TODO: plugins
# TODO: svga support - the Bochs sources explicitly cite /usr/include/vga.h
# TODO: a better way to organize the options