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