Some things about me that might help you help me:
Familiarity with Nix: I am new to Nix. Have a general idea of what it does but have not used it a whole lot.
Familiarity with Linux and programming: I am not new to Linux or Programming in general.
With that in mind, if this is the wrong place for me then I am happy to be directed to a forum more appropriate for me.
The issue at hand
I want to move to Nix but need Conda/Mamba with me for the work and research that I do. Could be wrong but having another package manager like inside of Nix seems to require a different kind of setup than a traditional *nix style OS.
If possible, please do not suggest solutions with anything other than 100% compatibility to a traditional conda install. I really only want to get conda working as closely as possible to a traditional non-nix style setup for now before I spend sometime in the near future to learn better nix-native methods.
What I have tried so far:
First approach
I installed this micromamba package from the nix repos. I added the suggested lines to my config.
The config was were:
environment.systemPackages = [
pkgs.micromamba
];
I could be wrong but the way the package behaved once installed is not what I expect from a regular conda install. I was able to isntall python packages with Conda but when I tried to access packages written with Conda, I given an error along the lines of “This package does not exist”. It seems Conda’s shell and Nix’s shell or paths are clashing or there is some other kind of kerfuffle going on.
For example, here is one of the error : /home/user/bash/envs/test/bin/R: line 272: /home/user/bash/envs/test/lib/R/bin/exec/R: cannot execute: required file not found
If this conflict between conda and nix can be solved, colud someone point in the right direction?
The second approach
I was able to find this blog post from someone else dealing with this exact same issue. The conda installed with that script is actually behaving fine and the way I am familiar with using conda. The only issue is that it uses an older version of conda.
I am trying to use a newer version and a different implementaion of conda i.e. miromamba
I modified the above best I could to look as follows:
{ pkgs ? import <nixpkgs> {} }:
let
# mamba installs it's packages and environments under this directory
installationPath = "~/.micromamba";
micromambaScript = pkgs.stdenv.mkDerivation rec {
name = "micromamba";
src = pkgs.fetchurl {
url = "https://micro.mamba.pm/api/micromamba/linux-64/latest";
sha256 = "9a07265264e738d59a858a79bb2dd91df9b6d1a17df9604b11995a38cf868cac";
};
unpackPhase = ''
mkdir -p $out
tar -xjf $src -C $out/tmp # Extract to a temporary directory
'';
installPhase = ''
mkdir -p $out/bin
mv $out/tmp/bin/* $out/bin/ # Move contents to the system's /bin
'';
};
in
(
pkgs.buildFHSUserEnv {
name = "mamba";
targetPkgs = pkgs: (
with pkgs; [
mamba
# Add here libraries that mamba packages require but aren't provided by
# mamba because it assumes that the system has them.
#
# For instance, for IPython, these can be found using:
# `LD_DEBUG=libs ipython --pylab`
xorg.libSM
xorg.libICE
xorg.libXrender
libselinux
# Just in case one installs a package with pip instead of mamba and pip
# needs to compile some C sources
gcc
# Add any other packages here, for instance:
emacs
git
]
);
profile = ''
# Add mamba 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=${pkgs.xorg.libX11}/share/X11/locale
'';
}
).env
I modified them with the following requirements in mind:
-
The original script downloads a script but the new needs to download and unpack a tarball that has a binary
-
Put the contents of the tarball in the
/bin
directory
Could someone let me know if things look right and if not what I can change? It would be helpful to not brick my partition and have to re-install things for this.