Building Mathemagix

I’m attempting to build the Mathemagix compiler and interpreter for an upcoming presentation on p-adic numbers.

http://www.mathemagix.org/

I’ve managed to compile it with the following derivation, but running the executable throws an error.

{ stdenv, fetchsvn, readline, ncurses, bison, libtool, gmp, mpfr }:

stdenv.mkDerivation {
  name = "Mathemagix";
  src = fetchsvn {
    sha256 = "sha256-kFo8SY7mg897yZJ03LFRP5cGVSsfrtmQ5VkO5VFBU0U=";
    url = "https://subversion.renater.fr/anonscm/svn/mmx/";
  };

  nativeBuildInputs = [ readline ncurses bison libtool gmp mpfr ];

  configurePhase = ''
    mkdir -p $out
    ./configure --enable-numerix --enable-mmxlight --prefix=$out/
  '';
}

The error is:

❯ ./result/bin/mmx-light 
--------------------------------------------------------------
|:*)          Welcome to Mathemagix-light 0.4             (*:|
|------------------------------------------------------------|
|  This software falls under the GNU General Public License  |
|          It comes without any warranty whatsoever          |
|                    www.mathemagix.org                      |
|                     (c) 2001--2010                         |
--------------------------------------------------------------
sh: line 1: basix-config: command not found
exception (../src/system.cpp:258: Cannot determine sysconf directory, C++ code)
terminate called after throwing an instance of 'mmx::exception'
fish: Job 1, './result/bin/mmx-light' terminated by signal SIGABRT (Abort)

Note: basix-config is in ./result/bin/

I’ve tried playing with some of options described in the following link, but only setting --prefix=$out seems to have improved the situation.

Installing mathemagix with configure

Although it appears to have not been updated for over a decade, it’s a rather magnificent piece of software and similar to Haskell in many ways. I imagine that getting this package to work might benefit many others as well.

This is my first attempt at building a package, so the answer might be obvious.

Thanks.

1 Like

I’ll give it a try tomorrow.

I would appreciate that very much.

I got it working:

❯ nix build .#mmx -L
❯ set PATH $PATH:./result/bin
❯ ./result/bin/mmx-light
--------------------------------------------------------------
|:*)          Welcome to Mathemagix-light 0.4             (*:|
|------------------------------------------------------------|
|  This software falls under the GNU General Public License  |
|          It comes without any warranty whatsoever          |
|                    www.mathemagix.org                      |
|                     (c) 2001--2010                         |
--------------------------------------------------------------
1] 

I’ll add it to nixpkgs during the day.

2 Likes

Here’s the PR: mathemagix: init at 11126 by drupol · Pull Request #305952 · NixOS/nixpkgs · GitHub

2 Likes

Thank you very much. I’m sure I will be able to use this to fix my code.

My only concern is that users might not have access to all of the libraries or “packages” as mathemagix calls them.

The creator of mathemagix is a prolific researcher in computations involving formal power series. I’m not sure users would be able to access these packages without rebuilding the entire thing from scratch. I will have to look into it further, but am quite busy this and next week.

Thank you again, it is very much appreciated.

Let’s improve it in nixpkgs and provide a good implementation. Step by step we’ll have something very flexible and powerful.

2 Likes

If you would tell me what’s left to do in there, I could polish it a bit more and make it ready.

Hmm, maybe include all mathemagix packages by default? There aren’t many and I suspect this would be desirable for most users. Providing an option to exclude packages might be beneficial but I’m not sure it would be necessary.

I will be able to provide better suggestions after finals in a couple weeks. I haven’t even checked which packages are installed by default, how big of files they are, etc. I’m also not super familiar with nixpkgs conventions. I have mainly stuck to my personal nixos config, but I’ve been wanting to learn how to make a nix package for a while now, for situations like this and to contribute to the community in some small way.

Unfortunately I wasn’t able to reproduce the build. Would it be easy for you to provide a standalone version on github that I could nix run?

nix run implies meta.mainProgram to be set. Since there’s no such thing, you can’t do it.

However, what you can do is the following:

nix shell github:drupol/nixpkgs/mathemagix/init#mathemagix

And you’ll be in a shell containing the mathemagix binaries.

1 Like

Ah, very nice. You are a legend.

1 Like