-
Notifications
You must be signed in to change notification settings - Fork 71
Compiling in NixOS
jthulhu edited this page Jun 16, 2023
·
4 revisions
A PR is pending for an update to Pharo. In the meantime, the following derivation can be used to build Pharo locally.
We will create a local repository with a single package, Pharo. Create a new directory, go in there and create a file pharo.nix
with the following content:
{ lib
, stdenv
, fetchurl
, unzip
, cmake
, SDL2
, gcc
, gnumake
, libffi
, libuuid
, openssl
, git
, freetype
, pixman
, libgit2
, runtimeShell
, libpng
, cairo
}:
let
pharo-sources = fetchurl {
# It is necessary to download from there instead of from the repository because that archive
# also contains artifacts necessary for the bootstrapping.
url = "https://files.pharo.org/vm/pharo-spur64-headless/Linux-x86_64/source/PharoVM-10.0.5-2757766-Linux-x86_64-c-src.zip";
sha256 = "08d04f6jc8kiwkx18ffig7wbjalqfryicxaw3am3kjsxsn2v19cb";
};
in
stdenv.mkDerivation {
pname = "pharo";
version = "10.0.5";
src = pharo-sources;
nativeBuildInputs = [
unzip
cmake
SDL2
gcc
gnumake
libffi
libuuid
openssl
git
freetype
pixman
];
cmakeFlags = [
# Necessary to perform the bootstrapping without already having Pharo available.
"-DGENERATED_SOURCE_DIR=."
"-DGENERATE_SOURCES=OFF"
# Prevents CMake from trying to download stuff.
"-DBUILD_BUNDLE=OFF"
];
installPhase = ''
cmake --build . --target=install
mkdir -p "$out/lib"
mkdir "$out/bin"
cp build/vm/*.so* "$out/lib/"
cp build/vm/pharo "$out/bin/.pharo"
cat >"$out/bin/pharo" <<EOF
#!${runtimeShell}
export LD_LIBRARY_PATH=${libgit2}/lib''${LD_LIBRARY_PATH:+:}\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${SDL2}/lib:\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${cairo}/lib:\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$out/lib:\$LD_LIBRARY_PATH
exec "$out/bin/.pharo" "\$@"
EOF
chmod +x "$out/bin/pharo"
'';
buildInputs = [
libgit2
SDL2
cairo
libpng
pixman
];
meta = with lib; {
description = "Clean and innovative Smalltalk-inspired environment";
homepage = "https://pharo.org";
longDescription = ''
Pharo's goal is to deliver a clean, innovative, free open-source
Smalltalk-inspired environment. By providing a stable and small core
system, excellent dev tools, and maintained releases, Pharo is an
attractive platform to build and deploy mission critical applications.
This package provides the executable VM. You should probably not care
about this package (which represents a packaging detail) and have a
look at the pharo-vm-core package instead.
Please fill bug reports on http://bugs.pharo.org under the 'Ubuntu
packaging (ppa:pharo/stable)' project.
'';
license = license.mit;
maintainers = [ ];
platforms = [ "x86_64-linux" ];
};
}
Then, create a default.nix
in the same directory, with the following content
{ pkgs ? import <nixpkgs> {} }:
{
pharo = pkgs.callPackage ./pharo.nix {};
}
Finally, build Pharo with nix-build
. pharo
is now available at result/bin/pharo
.