1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 unstableGitUpdater,
6 dosbox,
7
8 # Docs cause an immense increase in build time, up to 2 additional hours
9 withDocs ? false,
10 ghostscript,
11 withGUI ? false,
12}:
13
14stdenv.mkDerivation rec {
15 pname = "${passthru.prettyName}-unwrapped";
16 # nixpkgs-update: no auto update
17 version = "0-unstable-2025-05-07";
18
19 src = fetchFromGitHub {
20 owner = "open-watcom";
21 repo = "open-watcom-v2";
22 rev = "b168de07a7c32ad82b77dd56671b6a51a11dab70";
23 hash = "sha256-9NNJcDHxOo+NKZraGqsHqK5whO3nL0QTeh+imzhThTg=";
24 };
25
26 postPatch = ''
27 patchShebangs *.sh
28
29 for dateSource in bld/wipfc/configure; do
30 substituteInPlace $dateSource \
31 --replace-fail '`date ' '`date -ud "@$SOURCE_DATE_EPOCH" '
32 done
33
34 substituteInPlace bld/watcom/h/banner.h \
35 --replace-fail '__DATE__' "\"$(date -ud "@$SOURCE_DATE_EPOCH" +'%b %d %Y')\"" \
36 --replace-fail '__TIME__' "\"$(date -ud "@$SOURCE_DATE_EPOCH" +'%T')\""
37
38 substituteInPlace build/makeinit \
39 --replace-fail '$+$(%__CYEAR__)$-' "$(date -ud "@$SOURCE_DATE_EPOCH" +'%Y')"
40 ''
41 + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
42 substituteInPlace build/mif/local.mif \
43 --replace-fail '-static' ""
44 '';
45
46 nativeBuildInputs = [
47 dosbox
48 ]
49 ++ lib.optionals withDocs [
50 ghostscript
51 ];
52
53 configurePhase = ''
54 runHook preConfigure
55
56 export OWROOT=$(realpath $PWD)
57 export OWTOOLS=${if stdenv.cc.isClang then "CLANG" else "GCC"}
58 export OWDOCBUILD=${if withDocs then "1" else "0"}
59 export OWGHOSTSCRIPTPATH=${lib.optionalString withDocs "${ghostscript}/bin"}
60 export OWGUINOBUILD=${if withGUI then "0" else "1"}
61 export OWNOBUILD=
62 export OWDISTRBUILD=0
63 export OWDOSBOX=${dosbox}/bin/dosbox
64 export OWVERBOSE=0
65 export OWRELROOT=$out
66
67 source cmnvars.sh
68
69 runHook postConfigure
70 '';
71
72 buildPhase = ''
73 runHook preBuild
74
75 ./build.sh build
76
77 runHook postBuild
78 '';
79
80 installPhase = ''
81 runHook preInstall
82
83 ./build.sh cprel
84
85 runHook postInstall
86 '';
87
88 # Stripping breaks many tools
89 dontStrip = true;
90
91 passthru = {
92 prettyName = "open-watcom-v2";
93 updateScript = unstableGitUpdater {
94 url = "https://github.com/open-watcom/open-watcom-v2.git";
95 # no numerical releases, monthly "YYYY-MM-DD-Build" tags and daily "Current-build", "Last-CI-build" & "Coverity-scan" retagging
96 hardcodeZeroVersion = true;
97 };
98 };
99
100 meta = with lib; {
101 description = "V2 fork of the Open Watcom suite of compilers and tools";
102 longDescription = ''
103 A fork of Open Watcom: A C/C++/Fortran compiler and assembler suite
104 targeting a multitude of architectures (x86, IA-32, Alpha AXP, MIPS,
105 PowerPC) and operating systems (DOS, OS/2, Windows, Linux).
106
107 Main differences from Open Watcom 1.9:
108
109 - New two-phase build system - Open Watcom can be built by the host's
110 native C/C++ compiler or by itself
111 - Code generator properly initializes pointers by DLL symbol addresses
112 - DOS tools now support long file names (LFN) if appropriate LFN driver
113 is loaded by DOS
114 - Open Watcom is ported to 64-bit hosts (Win64, Linux x64)
115 - Librarian supports x64 CPU object modules and libraries
116 - RDOS 32-bit C run-time compact memory model libraries are fixed
117 - Resource compiler and Resource editors support Win64 executables
118 - Open Watcom text editor is now self-contained, it can be used as
119 standalone tool without any requirements for any additional files or
120 configuration
121 - Broken C++ compiler pre-compiled header template support is fixed
122 - Many C++ compiler crashes are fixed
123 - Debugger has no length limit for any used environment variable
124 ''
125 + lib.optionalString (!withDocs) ''
126
127 The documentation has been excluded from this build for build time reasons. It can be found here:
128 https://github.com/open-watcom/open-watcom-v2/wiki/Open-Watcom-Documentation
129 '';
130 homepage = "https://open-watcom.github.io";
131 license = licenses.watcom;
132 platforms = with platforms; windows ++ unix;
133 badPlatforms = platforms.riscv ++ [
134 "powerpc64-linux"
135 "powerpc64le-linux"
136 "mips64el-linux"
137 ];
138 maintainers = with maintainers; [ OPNA2608 ];
139 };
140}