initial commit
This commit is contained in:
130
gf-rgl.nix
Normal file
130
gf-rgl.nix
Normal file
@@ -0,0 +1,130 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
haskellPackages,
|
||||
ghc,
|
||||
makeWrapper,
|
||||
glibcLocales,
|
||||
# Optional: build only specific languages (comma-separated, e.g., "Eng,Swe,Ger")
|
||||
languages ? null,
|
||||
# Optional: build mode - "present", "alltenses", or "both"
|
||||
mode ? "both",
|
||||
}:
|
||||
|
||||
let
|
||||
# Build the language flag if languages are specified
|
||||
langFlag = if languages != null then "--langs=${languages}" else "";
|
||||
|
||||
# Build the mode flags
|
||||
modeFlags =
|
||||
if mode == "present" then
|
||||
"present"
|
||||
else if mode == "alltenses" then
|
||||
"alltenses"
|
||||
else
|
||||
""; # both is default
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "gf-rgl";
|
||||
version = "20250812";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "GrammaticalFramework";
|
||||
repo = "gf-rgl";
|
||||
rev = version;
|
||||
hash = "sha256-rqN5MV/XxChXC+Vs4aLIhRtyPQZNk0LQZ2TCdbd6wUw=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
haskellPackages.gf
|
||||
ghc
|
||||
makeWrapper
|
||||
glibcLocales
|
||||
];
|
||||
|
||||
# Disable parallel building as the GF build process isn't parallel-safe
|
||||
enableParallelBuilding = false;
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive
|
||||
export LANG=C.UTF-8
|
||||
export LC_ALL=C.UTF-8
|
||||
|
||||
# The RGL uses Setup.hs to build
|
||||
# We need to point it to the gf executable
|
||||
export GF=${haskellPackages.gf}/bin/gf
|
||||
|
||||
# Make sure GF can find its own libraries
|
||||
export GF_LIB_PATH=${haskellPackages.gf}/share/gf
|
||||
|
||||
echo "Using GF: $GF"
|
||||
echo "GF version: $($GF --version || echo 'unknown')"
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
# Build using the Haskell setup script
|
||||
# This compiles all the GF grammar files
|
||||
echo "Building GF-RGL with options: ${modeFlags} ${langFlag}"
|
||||
|
||||
runghc Setup.hs build ${modeFlags} ${langFlag} --gf=${haskellPackages.gf}/bin/gf --verbose
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# Install to the output directory
|
||||
mkdir -p $out/share/gf
|
||||
|
||||
# Copy the compiled files
|
||||
echo "Installing to $out/share/gf"
|
||||
runghc Setup.hs copy ${modeFlags} --dest=$out/share/gf
|
||||
|
||||
# Create a setup hook so other derivations can find this
|
||||
mkdir -p $out/nix-support
|
||||
cat > $out/nix-support/setup-hook << EOF
|
||||
export GF_LIB_PATH="\''${GF_LIB_PATH:+\''${GF_LIB_PATH}:}$out/share/gf"
|
||||
EOF
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# The RGL is architecture-independent (it's just compiled grammar files)
|
||||
# but we keep it architecture-specific for now to be safe
|
||||
# preferLocalBuild = true;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Grammatical Framework's Resource Grammar Library (RGL)";
|
||||
longDescription = ''
|
||||
The GF Resource Grammar Library is the standard library for Grammatical
|
||||
Framework. It covers the morphology and basic syntax of over 30 languages.
|
||||
|
||||
This package includes compiled grammar modules (.gfo files) that can be
|
||||
imported and used in GF applications.
|
||||
|
||||
Supported languages include: English, Swedish, German, French, Spanish,
|
||||
Italian, Dutch, Finnish, Russian, Bulgarian, Catalan, Danish, Norwegian,
|
||||
Polish, Romanian, Afrikaans, Amharic, Arabic, Basque, Chinese, Estonian,
|
||||
Greek, Hebrew, Hindi, Japanese, Korean, Latvian, Maltese, Mongolian,
|
||||
Nepali, Persian, Punjabi, Sindhi, Somali, Thai, Turkish, Urdu, and more.
|
||||
'';
|
||||
homepage = "https://www.grammaticalframework.org/";
|
||||
license = with licenses; [
|
||||
lgpl3Plus
|
||||
bsd3
|
||||
];
|
||||
maintainers = with maintainers; [ ];
|
||||
platforms = platforms.unix;
|
||||
# Note: This may take a while to build (30+ minutes for all languages)
|
||||
# Consider using binary caches or building with specific languages only
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user