smlnj: init at 2026.1

This commit is contained in:
Skye Soss
2026-04-27 19:56:21 -05:00
parent 7bebd81b8a
commit cd720d421f
6 changed files with 148 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ set -euo pipefail
dir="$(dirname "$0")"
url="https://smlnj.cs.uchicago.edu/dist/working/"
hashfile="$dir/hashes-legacy.json"
nixfile="$dir/legacy.nix"
nixfile="$dir/package.nix"
version="$(curl --silent "$url" \
| sed -n 's:.*<b>\([0-9]\{3\}\.[0-9.-]\+\)</b>.*:\1:p' \

View File

@@ -0,0 +1,96 @@
{
lib,
stdenv,
callPackage,
fetchFromGitHub,
fetchurl,
automake,
autoconf,
versionCheckHook,
}:
let
version = "2026.1";
src = fetchFromGitHub {
owner = "smlnj";
repo = "smlnj";
tag = "v${version}";
fetchSubmodules = true;
hash = "sha256-n5oWhignhFl8B/cXSO3g/KQXInZqT1A0Mp8GzLeGqNc=";
};
llvm = callPackage ./llvm.nix { inherit src version; };
bootFile =
if stdenv.hostPlatform.isUnix && stdenv.hostPlatform.isx86_64 then
fetchurl {
url = "https://smlnj.cs.uchicago.edu/dist/working/${version}/boot.amd64-unix.tgz";
hash = "sha256-caFguKkhFOjgJDtcOcF6YAbzFl2nQYXbtWCjvaBjL6o=";
}
else if stdenv.hostPlatform.isUnix && stdenv.hostPlatform.isAarch64 then
fetchurl {
url = "https://smlnj.cs.uchicago.edu/dist/working/${version}/boot.arm64-unix.tgz";
hash = "sha256-qygH0n163jiwm4CsltPeCCpHqnBxCHKP5O20GZyq1/0=";
}
else
throw "Unsupported host platform: ${stdenv.hostPlatform.config}";
in
stdenv.mkDerivation {
pname = "smlnj";
inherit src version;
nativeBuildInputs = [
autoconf
automake
];
__structuredAttrs = true;
strictDeps = true;
patchPhase = ''
runHook prePatch
unpackFile ${bootFile}
mkdir -pv runtime/bin runtime/lib
ln -s ${llvm}/bin/llvm-config runtime/bin/llvm-config
ln -s ${llvm}/lib/libCFGCodeGen.a runtime/lib/libCFGCodeGen.a
runHook postPatch
'';
buildPhase = ''
runHook preBuild
export INSTALLDIR=$out
mkdir -pv $out
./build.sh
runHook postBuild
'';
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "@SMLversion";
doInstallCheck = true;
passthru.llvm = llvm;
meta = {
description = "Standard ML of New Jersey, a Standard ML compiler";
homepage = "https://smlnj.org";
downloadPage = "https://smlnj.org/dist/working/${version}/install.html";
changelog = "https://smlnj.org/dist/working/${version}/README.html";
license = lib.licenses.bsd3;
sourceProvenance = with lib.sourceTypes; [
fromSource
binaryNativeCode
];
maintainers = [ lib.maintainers.skyesoss ];
mainProgram = "sml";
platforms = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform);
};
}

View File

@@ -0,0 +1,50 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
git,
python3,
ninja,
src,
version,
}:
let
targets =
lib.optional stdenv.targetPlatform.isx86_64 "X86"
++ lib.optional stdenv.targetPlatform.isAarch64 "AArch64";
in
stdenv.mkDerivation {
pname = "smlnj-llvm";
inherit src version;
sourceRoot = "${src.name}/runtime/llvm21";
strictDeps = true;
__structuredAttrs = true;
nativeBuildInputs = [
cmake
git
python3
ninja
];
cmakeFlags = [
"--preset=smlnj-llvm-release"
(lib.cmakeFeature "LLVM_TARGETS_TO_BUILD" (lib.concatStringsSep ";" targets))
(lib.cmakeBool "LLVM_ENABLE_DUMP" true)
];
meta = {
description = "Custom LLVM for Standard ML of New Jersey";
homepage = "https://smlnj.org";
license = lib.licenses.bsd3;
platforms = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
maintainers = with lib.maintainers; [
skyesoss
];
};
}

View File

@@ -4108,8 +4108,7 @@ with pkgs;
# smlnjBootstrap should be redundant, now that smlnj works on Darwin natively
smlnjBootstrap = callPackage ../development/compilers/smlnj/bootstrap.nix { };
smlnj = callPackage ../development/compilers/smlnj/legacy.nix { };
smlnj-legacy = callPackage ../development/compilers/smlnj/legacy.nix { };
smlnj = callPackage ../development/compilers/smlnj { };
squeak = callPackage ../development/compilers/squeak {
stdenv = clangStdenv;