nixpkgs/pkgs/by-name/sa/sage/sage-env.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

218 lines
5.2 KiB
Nix

{
stdenv,
lib,
writeTextFile,
sagelib,
sage-docbuild,
env-locations,
gfortran,
ninja,
bash,
coreutils,
gnused,
gnugrep,
gawk,
binutils,
pythonEnv,
python3,
pkg-config,
pari,
gap,
maxima,
singular,
fflas-ffpack,
givaro,
gd,
libpng,
linbox,
m4ri,
giac,
palp,
rWrapper,
gfan,
cddlib,
jmol,
tachyon,
glpk,
eclib,
sympow,
nauty,
sqlite,
ppl,
ecm,
lcalc,
rubiks,
blas,
lapack,
flint3,
gmp,
mpfr,
zlib,
gsl,
ntl,
jre8,
less,
}:
assert (!blas.isILP64) && (!lapack.isILP64);
# This generates a `sage-env` shell file that will be sourced by sage on startup.
# It sets up various environment variables, telling sage where to find its
# dependencies.
let
runtimepath = (
lib.makeBinPath ([
"@sage-local@"
"@sage-local@/build"
pythonEnv
gfortran # for inline fortran
ninja # for inline fortran via numpy.f2py
stdenv.cc # for cython
bash
coreutils
gnused
gnugrep
gawk
binutils.bintools
pkg-config
pari
gap
maxima.lisp-compiler
maxima
singular
giac
palp
# needs to be rWrapper since the default `R` doesn't include R's default libraries
rWrapper
gfan
cddlib
jmol
tachyon
glpk
eclib
sympow
nauty
sqlite
ppl
ecm
lcalc
rubiks
jre8 # only needed for `jmol` (https://sourceforge.net/p/jmol/mailman/message/58818762/), which will be optional in sage 10.5
less # needed to prevent transient test errors until https://github.com/ipython/ipython/pull/11864 is resolved
])
);
in
writeTextFile rec {
name = "sage-env";
destination = "/${name}";
text =
''
export PKG_CONFIG_PATH='${
lib.makeSearchPathOutput "dev" "lib/pkgconfig" [
# This should only be needed during build. However, since the doctests
# also test the cython build (for example in src/sage/misc/cython.py),
# it is also needed for the testsuite to pass. We could fix the
# testsuite instead, but since all the packages are also runtime
# dependencies it doesn't really hurt to include them here.
singular
blas
lapack
fflas-ffpack
givaro
gd
libpng
zlib
gsl
linbox
m4ri
]
}'
export SAGE_ROOT='${sagelib.src}'
''
+
# TODO: is using pythonEnv instead of @sage-local@ here a good
# idea? there is a test in src/sage/env.py that checks if the values
# SAGE_ROOT and SAGE_LOCAL set here match the ones set in env.py.
# we fix up env.py's SAGE_ROOT in sage-src.nix (which does not
# have access to sage-with-env), but env.py autodetects
# SAGE_LOCAL to be pythonEnv.
# setting SAGE_LOCAL to pythonEnv also avoids having to create
# python3, ipython, ipython3 and jupyter symlinks in
# sage-with-env.nix.
''
export SAGE_LOCAL='${pythonEnv}'
export SAGE_SHARE='${sagelib}/share'
export SAGE_ENV_CONFIG_SOURCED=1 # sage-env complains if sage-env-config is not sourced beforehand
orig_path="$PATH"
export PATH='${runtimepath}'
# set dependent vars, like JUPYTER_CONFIG_DIR
source "${sagelib.src}/src/bin/sage-env"
export PATH="$RUNTIMEPATH_PREFIX:${runtimepath}:$orig_path" # sage-env messes with PATH
export SAGE_LOGS="$TMPDIR/sage-logs"
export SAGE_DOC="''${SAGE_DOC_OVERRIDE:-doc-placeholder}"
export SAGE_DOC_SRC="''${SAGE_DOC_SRC_OVERRIDE:-${sagelib.src}/src/doc}"
# set locations of dependencies
. ${env-locations}/sage-env-locations
# needed for cython
export CC='${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc'
export CXX='${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++'
# cython needs to find these libraries, otherwise will fail with `ld: cannot find -lflint` or similar
export LDFLAGS='${
lib.concatStringsSep " " (
map (pkg: "-L${pkg}/lib") [
flint3
gap
glpk
gmp
mpfr
pari
zlib
eclib
gsl
ntl
jmol
sympow
]
)
}'
export CFLAGS='${
lib.concatStringsSep " " (
map (pkg: "-isystem ${pkg}/include") [
singular
gmp.dev
glpk
flint3
gap
mpfr.dev
]
)
}'
export CXXFLAGS=$CFLAGS
export SAGE_LIB='${sagelib}/${python3.sitePackages}'
export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data'
# for find_library
export DYLD_LIBRARY_PATH="${
lib.makeLibraryPath [
stdenv.cc.libc
singular
giac
gap
]
}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
'';
}
// {
# equivalent of `passthru`, which `writeTextFile` doesn't support
lib = sagelib;
docbuild = sage-docbuild;
}