push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
{
lib,
stdenvNoCC,
fetchurl,
qemu,
writeScript,
writeScriptBin,
ncurses,
bash,
coreutils,
unixtools,
}:
let
# We execute all OpenWatcom binaries in qemu-user, because otherwise
# some binaries (most notably the installer itself and wlib) fail to
# use the stat() systemcall. The failure mode is that it returns
# EOVERFLOW for completely legitimate requests. This seems like an
# incompatibility of new Linux kernels to run this ancient binary.
wrapLegacyBinary = writeScript "wrapLegacyBinary" ''
#!${bash}/bin/bash
set -eu
if [ $# -ne 2 ]; then
echo "Usage: $0 unwrapped-binary wrapped-binary"
exit 1
fi
IN="$(${coreutils}/bin/realpath $1)"
OUT="$2"
ARGV0="$(basename $2)"
cat > "$OUT" <<EOF
#!${bash}/bin/bash
TERMINFO=${ncurses}/share/terminfo TERM=vt100 exec ${qemu}/bin/qemu-i386 -0 $ARGV0 $IN "\$@"
EOF
chmod +x "$OUT"
'';
wrapInPlace = writeScriptBin "wrapInPlace" ''
#!${bash}/bin/bash
set -eu
if [ $# -ne 1 ]; then
echo "Usage: $0 unwrapped-binary"
exit 1
fi
TARGET="$1"
mv "$TARGET" "$TARGET-unwrapped"
chmod +x "$TARGET-unwrapped"
exec ${wrapLegacyBinary} "$TARGET-unwrapped" "$TARGET"
'';
in
stdenvNoCC.mkDerivation rec {
pname = "${passthru.prettyName}-unwrapped";
version = "1.9";
src = fetchurl {
url = "http://ftp.openwatcom.org/install/open-watcom-c-linux-${version}";
sha256 = "1wzkvc6ija0cjj5mcyjng5b7hnnc5axidz030c0jh05pgvi4nj7p";
};
nativeBuildInputs = [
wrapInPlace
unixtools.script
];
dontUnpack = true;
dontConfigure = true;
buildPhase = ''
cp ${src} install-bin-unwrapped
wrapInPlace install-bin-unwrapped
'';
installPhase = ''
# Command line options to do an unattended install are documented in
# https://github.com/open-watcom/open-watcom-v2/blob/master/bld/setupgui/setup.txt
script -c "./install-bin-unwrapped -dDstDir=$out -dFullInstall=1 -i"
for e in $(find $out/binl -type f -executable); do
echo "Wrapping $e"
wrapInPlace "$e"
done
'';
passthru.prettyName = "open-watcom-bin";
meta = with lib; {
description = "Project to maintain and enhance the Watcom C, C++, and Fortran cross compilers and tools";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
homepage = "http://www.openwatcom.org/";
license = licenses.watcom;
platforms = [
"x86_64-linux"
"i686-linux"
];
maintainers = [ maintainers.blitz ];
};
}

View File

@@ -0,0 +1,140 @@
{
stdenv,
lib,
fetchFromGitHub,
unstableGitUpdater,
dosbox,
# Docs cause an immense increase in build time, up to 2 additional hours
withDocs ? false,
ghostscript,
withGUI ? false,
}:
stdenv.mkDerivation rec {
pname = "${passthru.prettyName}-unwrapped";
# nixpkgs-update: no auto update
version = "0-unstable-2025-05-07";
src = fetchFromGitHub {
owner = "open-watcom";
repo = "open-watcom-v2";
rev = "b168de07a7c32ad82b77dd56671b6a51a11dab70";
hash = "sha256-9NNJcDHxOo+NKZraGqsHqK5whO3nL0QTeh+imzhThTg=";
};
postPatch = ''
patchShebangs *.sh
for dateSource in bld/wipfc/configure; do
substituteInPlace $dateSource \
--replace-fail '`date ' '`date -ud "@$SOURCE_DATE_EPOCH" '
done
substituteInPlace bld/watcom/h/banner.h \
--replace-fail '__DATE__' "\"$(date -ud "@$SOURCE_DATE_EPOCH" +'%b %d %Y')\"" \
--replace-fail '__TIME__' "\"$(date -ud "@$SOURCE_DATE_EPOCH" +'%T')\""
substituteInPlace build/makeinit \
--replace-fail '$+$(%__CYEAR__)$-' "$(date -ud "@$SOURCE_DATE_EPOCH" +'%Y')"
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
substituteInPlace build/mif/local.mif \
--replace-fail '-static' ""
'';
nativeBuildInputs = [
dosbox
]
++ lib.optionals withDocs [
ghostscript
];
configurePhase = ''
runHook preConfigure
export OWROOT=$(realpath $PWD)
export OWTOOLS=${if stdenv.cc.isClang then "CLANG" else "GCC"}
export OWDOCBUILD=${if withDocs then "1" else "0"}
export OWGHOSTSCRIPTPATH=${lib.optionalString withDocs "${ghostscript}/bin"}
export OWGUINOBUILD=${if withGUI then "0" else "1"}
export OWNOBUILD=
export OWDISTRBUILD=0
export OWDOSBOX=${dosbox}/bin/dosbox
export OWVERBOSE=0
export OWRELROOT=$out
source cmnvars.sh
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
./build.sh build
runHook postBuild
'';
installPhase = ''
runHook preInstall
./build.sh cprel
runHook postInstall
'';
# Stripping breaks many tools
dontStrip = true;
passthru = {
prettyName = "open-watcom-v2";
updateScript = unstableGitUpdater {
url = "https://github.com/open-watcom/open-watcom-v2.git";
# no numerical releases, monthly "YYYY-MM-DD-Build" tags and daily "Current-build", "Last-CI-build" & "Coverity-scan" retagging
hardcodeZeroVersion = true;
};
};
meta = with lib; {
description = "V2 fork of the Open Watcom suite of compilers and tools";
longDescription = ''
A fork of Open Watcom: A C/C++/Fortran compiler and assembler suite
targeting a multitude of architectures (x86, IA-32, Alpha AXP, MIPS,
PowerPC) and operating systems (DOS, OS/2, Windows, Linux).
Main differences from Open Watcom 1.9:
- New two-phase build system - Open Watcom can be built by the host's
native C/C++ compiler or by itself
- Code generator properly initializes pointers by DLL symbol addresses
- DOS tools now support long file names (LFN) if appropriate LFN driver
is loaded by DOS
- Open Watcom is ported to 64-bit hosts (Win64, Linux x64)
- Librarian supports x64 CPU object modules and libraries
- RDOS 32-bit C run-time compact memory model libraries are fixed
- Resource compiler and Resource editors support Win64 executables
- Open Watcom text editor is now self-contained, it can be used as
standalone tool without any requirements for any additional files or
configuration
- Broken C++ compiler pre-compiled header template support is fixed
- Many C++ compiler crashes are fixed
- Debugger has no length limit for any used environment variable
''
+ lib.optionalString (!withDocs) ''
The documentation has been excluded from this build for build time reasons. It can be found here:
https://github.com/open-watcom/open-watcom-v2/wiki/Open-Watcom-Documentation
'';
homepage = "https://open-watcom.github.io";
license = licenses.watcom;
platforms = with platforms; windows ++ unix;
badPlatforms = platforms.riscv ++ [
"powerpc64-linux"
"powerpc64le-linux"
"mips64el-linux"
];
maintainers = with maintainers; [ OPNA2608 ];
};
}

View File

@@ -0,0 +1,171 @@
# Arguments that this derivation gets when it is created with `callPackage`
{
stdenv,
lib,
symlinkJoin,
makeWrapper,
runCommand,
file,
}:
open-watcom:
let
wrapper =
{ }:
let
archToBindir =
with stdenv.hostPlatform;
if isx86 then
"bin"
else if isAarch then
"arm"
# we don't support running on AXP
# don't know what MIPS, PPC bindirs are called
else
throw "Don't know where ${system} binaries are located!";
binDirs =
with stdenv.hostPlatform;
if isWindows then
[
(lib.optionalString is64bit "${archToBindir}nt64")
"${archToBindir}nt"
(lib.optionalString is32bit "${archToBindir}w")
]
else if isDarwin then
[
(lib.optionalString is64bit "${archToBindir}o64")
# modern Darwin cannot execute 32-bit code anymore
(lib.optionalString is32bit "${archToBindir}o")
]
else
[
(lib.optionalString is64bit "${archToBindir}l64")
"${archToBindir}l"
];
# TODO
# This works good enough as-is, but should really only be targetPlatform-specific
# but we don't support targeting DOS, OS/2, 16-bit Windows etc Nixpkgs-wide so this needs extra logic
includeDirs =
with stdenv.hostPlatform;
[
"h"
]
++ lib.optional isWindows "h/nt"
++ lib.optional isLinux "lh";
listToDirs = list: lib.strings.concatMapStringsSep ":" (dir: "${placeholder "out"}/${dir}") list;
name = "${open-watcom.passthru.prettyName}-${open-watcom.version}";
in
symlinkJoin {
inherit name;
paths = [ open-watcom ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
mkdir $out/bin
for binDir in ${lib.strings.concatStringsSep " " binDirs}; do
for exe in $(find ${open-watcom}/$binDir \
-type f -executable \
${lib.optionalString stdenv.hostPlatform.isLinux "-not -iname '*.so' -not -iname '*.exe'"} \
); do
if [ ! -f $out/bin/$(basename $exe) ]; then
makeWrapper $exe $out/bin/$(basename $exe) \
--set WATCOM ${open-watcom} \
--prefix PATH : ${listToDirs binDirs} \
--set EDPATH ${open-watcom}/eddat \
--set INCLUDE ${listToDirs includeDirs}
fi
done
done
'';
passthru = {
unwrapped = open-watcom;
tests =
let
wrapped = wrapper { };
in
{
simple = runCommand "${name}-test-simple" { nativeBuildInputs = [ wrapped ]; } ''
cat <<EOF >test.c
#include <stdio.h>
int main() {
printf ("Testing OpenWatcom C89 compiler.\n");
return 0;
}
EOF
cat test.c
wcl386 -fe=test_c test.c
# Only test execution if hostPlatform is targetable
${lib.optionalString (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isAarch) "./test_c"}
cat <<EOF >test.cpp
#include <string>
#include <iostream>
int main() {
std::cout << "Testing OpenWatcom C++ library implementation." << std::endl;
watcom::istring HELLO ("HELLO");
if (HELLO != "hello") {
return 1;
}
if (HELLO.find ("ello") != 1) {
return 2;
}
return 0;
}
EOF
cat test.cpp
wcl386 -fe=test_cpp test.cpp
# Only test execution if hostPlatform is targetable
${lib.optionalString (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isAarch) "./test_cpp"}
touch $out
'';
cross =
runCommand "${name}-test-cross"
{
nativeBuildInputs = [
wrapped
file
];
}
''
cat <<EOF >test.c
#include <stdio.h>
int main() {
printf ("Testing OpenWatcom cross-compilation.\n");
return 0;
}
EOF
cat test.c
echo "Test compiling"
wcl386 -bcl=linux -fe=linux test.c
wcl386 -bcl=nt -fe=nt test.c
wcl386 -bcl=dos4g -fe=dos4g test.c
wcl -bcl=windows -fe=windows test.c
wcl -bcl=dos -fe=dos test.c
echo "Test file format"
file ./linux
file ./linux | grep "32-bit" | grep -q "Linux"
file ./nt.exe
file ./nt.exe | grep "PE32" | grep -q "Windows"
file ./dos4g.exe
file ./dos4g.exe | grep "MS-DOS" | grep -q "executable, LE"
file ./windows.exe
file ./windows.exe | grep "MS-DOS" | grep -q "Windows 3.00"
file ./dos.exe
file ./dos.exe | grep "MS-DOS" | grep -v "LE" | grep -qv "Windows 3."
touch $out
'';
};
};
inherit (open-watcom) meta;
};
in
lib.makeOverridable wrapper