nixpkgs/pkgs/applications/science/math/sage
Mauricio Collares e21968aa89
Merge pull request #294062 from collares/sage-10.3
sage: 10.2 -> 10.3
2024-03-20 13:21:12 +01:00
..
patches sage, sageWithDoc: 10.0 -> 10.2 2024-01-24 15:26:55 +01:00
python-modules sage, sageWithDoc: 10.2 -> 10.3 2024-03-20 11:46:58 +01:00
default.nix sage, sageWithDoc: 10.2 -> 10.3 2024-03-20 11:46:58 +01:00
dist-tests.nix
env-locations.nix sage, sageWithDoc: 10.2 -> 10.3 2024-03-20 11:46:58 +01:00
README.md treewide: Fix typos 2023-09-28 19:06:13 +02:00
sage-env.nix sage, sageWithDoc: 10.2 -> 10.3 2024-03-20 11:46:58 +01:00
sage-src.nix sage, sageWithDoc: 10.2 -> 10.3 2024-03-20 11:46:58 +01:00
sage-tests.nix treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
sage-with-env.nix python311Packages.zope-*: rename from zope_* 2024-01-06 21:04:16 +01:00
sage.nix treewide: add meta.mainProgram to packages with a single binary 2024-03-19 03:14:51 +01:00
sagedoc.nix sage, sageWithDoc: 10.0 -> 10.2 2024-01-24 15:26:55 +01:00
sagelib.nix sage, sageWithDoc: 10.2 -> 10.3 2024-03-20 11:46:58 +01:00
threejs-sage.nix

Sage on nixos

Sage is a pretty complex package that depends on many other complex packages and patches some of those. As a result, the sage nix package is also quite complex.

Don't feel discouraged to fix, simplify or improve things though. The individual files have comments explaining their purpose. The most important ones are default.nix linking everything together, sage-src.nix adding patches and sagelib.nix building the actual sage package.

The sage build is broken

First you should find out which change to nixpkgs is at fault (if you don't already know). You can use git-bisect for that (see the manpage).

If the build broke as a result of a package update, try those solutions in order:

  • search the sage GitHub repo for keywords like "Upgrade ". Maybe somebody has already proposed a patch that fixes the issue. You can then add a fetchpatch to sage-src.nix.

  • check if gentoo, debian or arch linux already solved the problem. You can then again add a fetchpatch to sage-src.nix. If applicable you should also propose the patch upstream.

  • fix the problem yourself. First clone the sagemath source and then check out the sage version you want to patch:

[user@localhost ~]$ git clone https://github.com/sagemath/sage.git
[user@localhost ~]$ cd sage
[user@localhost sage]$ git checkout 9.8 # substitute the relevant version here

Then make the needed changes and generate a patch with git diff:

[user@localhost ~]$ <make changes>
[user@localhost ~]$ git diff -u > /path/to/nixpkgs/pkgs/applications/science/math/sage/patches/name-of-patch.patch

Now just add the patch to sage-src.nix and test your changes. If they fix the problem, submit a PR upstream (refer to sages Developer's Guide for further details).

  • pin the package version in default.nix and add a note that explains why that is necessary.

I want to update sage

You'll need to change the version field in sage-src.nix. Afterwards just try to build and let nix tell you which patches no longer apply (hopefully because they were adopted upstream). Remove those.

Hopefully the build will succeed now. If it doesn't and the problem is obvious, fix it as described in The sage build is broken. If the problem is not obvious, you can try to first update sage to an intermediate version (remember that you can also set the version field to any git revision of sage) and locate the sage commit that introduced the issue. You can even use git-bisect for that (it will only be a bit tricky to keep track of which patches to apply). Hopefully after that the issue will be obvious.

Well, that didn't help!

If you couldn't fix the problem, create a GitHub issue on the nixpkgs repo and ping the sage maintainers (as listed in the sage package). Describe what you did and why it didn't work. Afterwards it would be great if you help the next guy out and improve this documentation!