[tools] Initial support for nix shell/develop #3519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Nix shell/develop provides similar functionality to 'magic shell' but works with the Nix package manager (https://nixos.org/download/) and is generally used to manage an entire operating system.
Nix does not follow the FHS standard which means that magic does not work on systems using Nix out of the box and providing such a developer environment makes it easier for people using Nix to use and contribute to the software provided by Modular. On a system with a default Nix installation the shell can be entered by going to the mojo repository path and executing 'nix-shell'.
With flake support enabled it also works with 'nix develop'.
The Nix package manager is used in the NixOS Linux distribution and enables the configuration of the entire system declaratively in a functional language also called Nix.
But it can also be used on any other Linux distribution and macOS with the same guarantees as on NixOS with the exception that it uses the base system on the lowest layer in this case instead of it's own kernel.
With https://github.com/NixOS/nixpkgs there exists a repository for packaging software which is also a possible future path with the Modular products but currently I believe that it's not yet feasible.
I thought that the mojo repository is for now the best place to centralize the support for a Nix dev shell even though I realize that this is not something of high importance for Modular.
Nix might also be of interest because it could potentially also being used to build containers (https://nix.dev/tutorials/nixos/building-and-running-docker-images.html) and an increasing number of repositories provide a flake.nix file in the repository to package the current upstream version directly in comparison to the nixpkgs approach.
I know the chances are slim that this gets merged but I thought I will try.
I tested the shell on NixOS but was not able to test on macOS because I don't have access to it.
Anybody interested in trying it out can do so by installing the Nix package manager by following the instructions on https://nixos.org/download and running 'nix-shell' in the mojo repository directory with the nix files present.