|
| 1 | +{ lib |
| 2 | +, stdenv |
| 3 | +, fetchurl |
| 4 | +, runCommand |
| 5 | +, makeWrapper |
| 6 | +, buildFHSUserEnv |
| 7 | +, libselinux |
| 8 | +, xorg |
| 9 | +# Conda installs its packages and environments under this directory |
| 10 | +, installationPath ? "~/.conda" |
| 11 | +# Conda manages most pkgs itself, but expects a few to be on the system. |
| 12 | +, condaDeps ? [ stdenv.cc xorg.libSM xorg.libICE xorg.libXrender libselinux ] |
| 13 | +# Any extra nixpkgs you'd like available in the FHS env for Conda to use |
| 14 | +, extraPkgs ? [ ] |
| 15 | +}: |
| 16 | + |
| 17 | +# How to use this package? |
| 18 | +# |
| 19 | +# First-time setup: this nixpkg downloads the conda installer and provides a FHS |
| 20 | +# env in which it can run. On first use, the user will need to install conda to |
| 21 | +# the installPath using the installer: |
| 22 | +# $ nix-env -iA conda |
| 23 | +# $ conda-shell |
| 24 | +# $ conda-install |
| 25 | +# |
| 26 | +# Under normal usage, simply call `conda-shell` to activate the FHS env, |
| 27 | +# and then use conda commands as normal: |
| 28 | +# $ conda-shell |
| 29 | +# $ conda install spyder |
| 30 | +let |
| 31 | + version = "4.3.31"; |
| 32 | + src = fetchurl { |
| 33 | + url = "https://repo.continuum.io/miniconda/Miniconda3-${version}-Linux-x86_64.sh"; |
| 34 | + sha256 = "1rklq81s9v7xz1q0ha99w2sl6kyc5vhk6b21cza0jr3b8cgz0lam"; |
| 35 | + }; |
| 36 | + |
| 37 | + conda = runCommand "conda-install" { buildInputs = [ makeWrapper ]; } |
| 38 | + '' |
| 39 | + mkdir -p $out/bin |
| 40 | + cp ${src} $out/bin/miniconda-installer.sh |
| 41 | + chmod +x $out/bin/miniconda-installer.sh |
| 42 | +
|
| 43 | + makeWrapper \ |
| 44 | + $out/bin/miniconda-installer.sh \ |
| 45 | + $out/bin/conda-install \ |
| 46 | + --add-flags "-p ${installationPath}" \ |
| 47 | + --add-flags "-b" |
| 48 | + ''; |
| 49 | +in |
| 50 | + buildFHSUserEnv { |
| 51 | + name = "conda-shell"; |
| 52 | + targetPkgs = pkgs: (builtins.concatLists [ [ conda ] condaDeps extraPkgs]); |
| 53 | + profile = '' |
| 54 | + # Add conda to PATH |
| 55 | + export PATH=${installationPath}/bin:$PATH |
| 56 | + # Paths for gcc if compiling some C sources with pip |
| 57 | + export NIX_CFLAGS_COMPILE="-I${installationPath}/include" |
| 58 | + export NIX_CFLAGS_LINK="-L${installationPath}lib" |
| 59 | + # Some other required environment variables |
| 60 | + export FONTCONFIG_FILE=/etc/fonts/fonts.conf |
| 61 | + export QTCOMPOSE=${xorg.libX11}/share/X11/locale |
| 62 | + ''; |
| 63 | + |
| 64 | + meta = { |
| 65 | + description = "Conda is a package manager for Python"; |
| 66 | + homepage = https://conda.io/; |
| 67 | + platforms = lib.platforms.linux; |
| 68 | + license = lib.licenses.bsd3; |
| 69 | + maintainers = with lib.maintainers; [ jluttine bhipple ]; |
| 70 | + }; |
| 71 | + } |
0 commit comments