2018-02-18 18:21:25 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, runCommand
|
|
|
|
, makeWrapper
|
|
|
|
, buildFHSUserEnv
|
|
|
|
, libselinux
|
2019-06-18 09:13:23 +01:00
|
|
|
, libarchive
|
2019-07-20 05:33:30 +01:00
|
|
|
, libGL
|
2018-02-18 18:21:25 +00:00
|
|
|
, xorg
|
|
|
|
# Conda installs its packages and environments under this directory
|
|
|
|
, installationPath ? "~/.conda"
|
|
|
|
# Conda manages most pkgs itself, but expects a few to be on the system.
|
2019-07-20 05:33:30 +01:00
|
|
|
, condaDeps ? [ stdenv.cc xorg.libSM xorg.libICE xorg.libX11 xorg.libXau xorg.libXi xorg.libXrender libselinux libGL ]
|
2018-02-18 18:21:25 +00:00
|
|
|
# Any extra nixpkgs you'd like available in the FHS env for Conda to use
|
|
|
|
, extraPkgs ? [ ]
|
|
|
|
}:
|
|
|
|
|
|
|
|
# How to use this package?
|
|
|
|
#
|
|
|
|
# First-time setup: this nixpkg downloads the conda installer and provides a FHS
|
|
|
|
# env in which it can run. On first use, the user will need to install conda to
|
|
|
|
# the installPath using the installer:
|
|
|
|
# $ nix-env -iA conda
|
|
|
|
# $ conda-shell
|
|
|
|
# $ conda-install
|
|
|
|
#
|
|
|
|
# Under normal usage, simply call `conda-shell` to activate the FHS env,
|
|
|
|
# and then use conda commands as normal:
|
|
|
|
# $ conda-shell
|
|
|
|
# $ conda install spyder
|
|
|
|
let
|
2019-06-26 11:01:35 +01:00
|
|
|
version = "4.6.14";
|
2018-02-18 18:21:25 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://repo.continuum.io/miniconda/Miniconda3-${version}-Linux-x86_64.sh";
|
2019-06-26 11:01:35 +01:00
|
|
|
sha256 = "1gn43z1y5zw4yv93q1qajwbmmqs83wx5ls5x4i4llaciba4j6sqd";
|
2018-02-18 18:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
conda = runCommand "conda-install" { buildInputs = [ makeWrapper ]; }
|
|
|
|
''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp ${src} $out/bin/miniconda-installer.sh
|
|
|
|
chmod +x $out/bin/miniconda-installer.sh
|
|
|
|
|
|
|
|
makeWrapper \
|
|
|
|
$out/bin/miniconda-installer.sh \
|
|
|
|
$out/bin/conda-install \
|
|
|
|
--add-flags "-p ${installationPath}" \
|
|
|
|
--add-flags "-b"
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
buildFHSUserEnv {
|
2019-06-26 12:48:12 +01:00
|
|
|
name = "conda-shell";
|
2018-02-18 18:21:25 +00:00
|
|
|
targetPkgs = pkgs: (builtins.concatLists [ [ conda ] condaDeps extraPkgs]);
|
|
|
|
profile = ''
|
|
|
|
# Add conda to PATH
|
|
|
|
export PATH=${installationPath}/bin:$PATH
|
|
|
|
# Paths for gcc if compiling some C sources with pip
|
|
|
|
export NIX_CFLAGS_COMPILE="-I${installationPath}/include"
|
|
|
|
export NIX_CFLAGS_LINK="-L${installationPath}lib"
|
|
|
|
# Some other required environment variables
|
|
|
|
export FONTCONFIG_FILE=/etc/fonts/fonts.conf
|
|
|
|
export QTCOMPOSE=${xorg.libX11}/share/X11/locale
|
2019-06-18 09:13:23 +01:00
|
|
|
export LIBARCHIVE=${libarchive.lib}/lib/libarchive.so
|
2021-01-03 01:09:01 +00:00
|
|
|
# Allows `conda activate` to work properly
|
|
|
|
source ${installationPath}/etc/profile.d/conda.sh
|
2018-02-18 18:21:25 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Conda is a package manager for Python";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://conda.io/";
|
2018-02-18 18:21:25 +00:00
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
maintainers = with lib.maintainers; [ jluttine bhipple ];
|
|
|
|
};
|
|
|
|
}
|