I just ran into this issue setting up a new Python environment.
It’s weird because I’ve been using micromamba+nix for quite some time now (I wrote the micromamba package) and haven’t seen this until now.
Not sure if it’s because micromamba changed something in the generated script in some recent version or if something’s different because this new env I’m setting up uses flakes
Anyway the fix for me was using eval "$(micromamba shell hook --shell=posix)"
Thank you for your answer. Unfortunately, that doesn’t work for me. I don’t know, maybe it’s because I’m using fish as my default shell. I will try it with flakes. Maybe it makes a difference.
Hi I’m having the same issue. I also use fish as shell and set up dash as a replacement for bash according to the wiki. Since I’m quite new to Nix I’m having trouble setting up an environment using a flake.
My flake looks like this:
{
description = “Flake to set up python environment with micromamba”;
But when executing it with nix-shell python-flake.nix it tells me there is an unexpected }.
I have checked the flake now multiple times and as far as I know there is no wrong {}. Am I missing some technicality here?
I have my system configured via a flake as well and it works fine. But there I did a flake init first, but executing it in my dev folder I get:
DBI connect(‘dbname=/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite’,’’,…) failed: unable to open database file at /run/current-system/sw/bin/command-not-found line 13.
cannot open database `/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite’ at /run/current-system/sw/bin/command-not-found line 13.
I hope you can help me out here. Setting up the environment is the last thing I need to do to switch over to NixOS.
Thank you and sorry for the long post.
Edit: I don’t know why only the second half of the flake is formatted correctly, sorry for the inconvenience.
You are missing an assignnent here. Though then you were still not following the flake output schema correctly.
What you probably want is this instead:
in {
devShells.x86_64-linux.default = fhs.env;
};
Though you are still using builtins.getEnv then which is “impure” and therefore not allowed in flakes.
You are running a command that does not exist in PATH and you also have not set up the command-not-found database. What has been the command you ran? If the command was literally flake init, then you need to use nix flake init instead! Anyway. That is rarely necessary and does not do any magic setup. It just gives you an empty flake.nix.
Because it was intended by at least 4 spaces or a tab. In general you might want to prefer markdown fenced codeblocks:
```nix
{} # this is nix code
```
PS: If you have follow up questions, please open another thread. This is marked as solved already, and an ongoing discussion here might be missed by people who filter “solved” threads.
Hi, I had the same problem, and posted solution did not work for me. Good news: I found a workaround, which was to “patch” the micromamba shell hook using sed to comment out the lines using complete builtin before evaluation. Now nix-shell seems to work for me, and shell completion seems to work too (not sure what those now-commented-out lines did).
This is probably not a super stable solution, but nothing else I could find would fix this! By the way, the root of the issue, as I understand it, has to do with the profile = ''...'' commands running with bash rather than bashInteractive (bash-interactive). I found when I added echo $BASH to the profile = ''...'' section of this shell.nix, it would point to a bash binary in the nix store, rather than bash-interactive. I tried for a few hours to figure out how to switch the shell used for the profile commands, but had no luck (adding pkgs.bashInteractive to targetPkgs did not work). If anyone has some advice for where to report this for a proper upstream fix, that would be much appreciated.