Soft-migrating off mise / .tool-versions

TL;DR. I am looking for a way to automatically activate versions of tools specified in .tool-versions file. I use mise today in my non-nix environment, but mise doesn’t seem to work in NixOS the way I expect it to.

In essense, mise is similar to asdf.


Some of projects at work have a file called .tool-versions.

Upon entering a folder containing .tool-versions file, if a tool called mise is installed on the system, the mise automatically switches to use the versions of languages specified in .tool-versions. Or it will suggests the tool versions are missing, in which case you can run mise install to install them.

For example, if a given folder contains .tool-versions with the following contents:

erlang 26.2.3
elixir 1.16.2-otp-26

…entering a folder will trigger mise to automatically update PATH (or do whatever it needs to do…) in order for binaries for both programming languages to become available.

The problem is, in mise doesn’t seem to work in nixos. At least in my practice. if I enter a folder containing .tool-versions and run mise install then I get an error:

Full error log
mise i
mise ⚠️ erlang is a community-developed plugin
mise url: https://github.com/asdf-vm/asdf-erlang
 Would you like to install erlang? Yes
Downloading kerl...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 74085  100 74085    0     0   239k      0 --:--:-- --:--:-- --:--:--  239k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  101M  100  101M    0     0  41.0M      0  0:00:02  0:00:02 --:--:-- 54.4M
checking target system type... aarch64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
configure: error: in `/home/eugene/.local/share/mise/plugins/erlang/kerl-home/builds/asdf_26.2.3/otp_src_26.2.3/erts':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
ERROR: /home/eugene/.local/share/mise/plugins/erlang/kerl-home/builds/asdf_26.2.3/otp_src_26.2.3/erts/configure failed!
./configure: line 370: kill: (-204057) - No such process
mise ~/.local/share/mise/plugins/erlang/bin/install failed
Downloading kerl...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 74085  100 74085    0     0   239k      0 --:--:-- --:--:-- --:--:--  239k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  101M  100  101M    0     0  41.0M      0  0:00:02  0:00:02 --:--:-- 54.4M
checking target system type... aarch64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
configure: error: in `/home/eugene/.local/share/mise/plugins/erlang/kerl-home/builds/asdf_26.2.3/otp_src_26.2.3/erts':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
ERROR: /home/eugene/.local/share/mise/plugins/erlang/kerl-home/builds/asdf_26.2.3/otp_src_26.2.3/erts/configure failed!
./configure: line 370: kill: (-204057) - No such process

I believe the error is reasonable, because I don’t have any build utilities installed. After thinking more, trying to make mise work could be dead-end, as to make it work I would have to make sure all build-time dependencies for Erlang and Elixir are installed…

I believe a different approach is needed. Something like:

  1. when I enter a directory which contains .tool-versions,
  2. automatically, run a special nix shell that has necessary tool versions enabled

If “automatically” is not possible, I think I can settle on “run some nix dev env shell”. But I’ve never created a shell before. Any pointers as to how do I create a shell? I’d need a separate shell for each project, of which I have a several, each using its own set of language versions.

I am new to nix - any idea where to start with this?

P.S. .tool-versions needs to stay, since all other team members are not planning to switch to nix.

There are different tools you are looking for:

  1. direnv to automatically activate “shell” like mise when you enter the directory;
  2. mise2nix, it doesn’t exist (or I’m not aware of), but there is a bunch of something2nix, check dream2nix presentation;
    • Write your own mise2nix, tend to be a hard work (check dream2nix video)
  3. create the shell yourself or use something like devshell or devenv, etc.
    • I like more devshell but devenv seems to be more future-proof.
    • devhshell/devenv provide an experience similar to a NixOS for a nix shell.

Because of 2, unless you are really engaged into creating a mise2nix, there a two more pragmatic approaches:

  • Make mise work with NixOS isn’t a dead-end:
    :heavy_plus_sign: your mise environment will be in sync with other team members;
    :heavy_minus_sign: Is not declarative;
    :heavy_minus_sign: won’t leverage nix public cache (have to build in your machine);
  • Mirror mise information by hand in a nix shell:
    :heavy_plus_sign: don’t need to compile requirements by yourself;
    :heavy_minus_sign: it may be the case that mise version mismatch nix version;
    :heavy_minus_sign: has to sync it manually with mise;

In both cases, direnv and devshell/devenv are good additions to your task of working with mise.

If you still decide to create a mise2nix, do your first project by mirroring it by hand, as it would give you enough baggage to start, because you would basically automate this process.

2 Likes

Thank you for a good summary! You made me realize I could actually try and make mise work, which I did, and this will do for now.

I’ll look into making my system flake reproducible by moving away from mise s the next step.