I’m new to nix/direnv and trying to use direnv on my mac. Unfortunately I have to use conda/mamba for some of my python projects at work and I’m having trouble getting these tools to work with direnv. I found Python - NixOS Wiki which uses pkgs.buildFHSUserEnv
to isolate the environment on linux. Is anybody aware of a way to approximate this functionality on mac?
Here is my config:
{
description = "Operations Mamba Shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
packages = [ pkgs.micromamba ];
shellHook = ''
set -e
eval "$(micromamba shell hook -s bash)"
export MAMBA_ROOT_PREFIX=${builtins.getEnv "PWD"}/.mamba
micromamba create -q -n my-mamba-environment
micromamba activate my-mamba-environment
micromamba install --yes -f conda-requirements.txt -c conda-forge
set +e
'';
};
});
}
Here is the output I see:
direnv: loading ~/workspace/operations/.envrc
nix-direnv: error current version v2.3.0 is older than the desired version v2.4.0
direnv: loading https://raw.githubusercontent.com/nix-community/nix-direnv/2.4.0/direnvrc (sha256-XQzUAvL6pysIJnRJyR7uVpmUSZfc7LSgWQwq/4mBr1U=)
direnv: using flake
warning: Git tree '/Users/ben/workspace/operations' is dirty
warning: Git tree '/Users/ben/workspace/operations' is dirty
direnv: nix-direnv: renewed cache
/Users/ben/.cache/direnv/cas/5d0cd402f2faa72b08267449c91eee5699944997dcecb4a0590c2aff8981af55:2109: complete: command not found
/Users/ben/.cache/direnv/cas/5d0cd402f2faa72b08267449c91eee5699944997dcecb4a0590c2aff8981af55:280: pop_var_context: head of shell_variables not a function context
environment:1073: pop_var_context: head of shell_variables not a function context
./.envrc:4: pop_var_context: head of shell_variables not a function context
direnv: error exit status 127