DEV Community

Cover image for NixOs - Your portable dev enviroment

Posted on

NixOs - Your portable dev enviroment

Good morning everyone and happy Monday ☕,
it's been a couple of weeks since we last spoke, with Easter Monday in between, there's been a way to recharge the batteries a bit for everyone, at least I hope so.

I also had the chance to work on some personal projects and to start working on some evolutions for this Newsletter; but we will talk about it later calmly; starting with, as far as I'm concerned, the small project written with Tauri (do you remember Tauri? You can catch up with the newsletter here 😉) which started to streamline the various tasks I perform weekly to prepare the newsletter 😁
But let's get to the point! What am I talking to you about today?

Today is the time for a tool that I had set aside for quite some time, of which I had heard good things but had not had the opportunity and time to try yet. Instead, I was able to take advantage of these calm days to test it and discover it, finally.

Today I want to talk to you about Nixos. What is it? Nixos is a declarative and reproducible OS, partly taking the words used on their own page. What does that mean?

In reality, many things: in the simplest case, it is the possibility of having ad hoc shell environments, with the tools you want in the version you prefer ready to be used without necessarily installing them on your machine (for example, if you need to install a different version of a language or want to install any tool without risking making unwanted changes to your daily development environment). Just specify what you want to have installed and a dedicated virtual environment will be created to work on. All without having to give up your local files, because only the environment will be installed without having to install an entire OS or instantiate a docker container.

Let's make an example: suppose you want to test Python without installing it locally; by running the command nix-shell -p python3 you will find yourself in a protected environment where you can do all the tests you want and then remove it. In general, the number of installable packages is large and allows to meet the needs of everyone.

Of course, these shells are very fleeting environments and, although they can be fun to use occasionally, their portability and reproducibility are limited:
on the other hand, Nixos makes these characteristics its strong point; this is because it allows you to write config files that guarantee you have the same environment available everywhere.

In a few lines of code, you can define all the tools you need to work (git, vim, npm, nvm, php, composer...) and be sure to have a reproducible development environment wherever you want, ready to use. In other words, it is a sort of docker, but oriented towards the creation of local environments. More information on this can be found in this section of the documentation and in the following ones.

I personally believe that this tool can be very interesting and useful in many ways, both when we want to experiment with something and when we need to recreate a specific environment on the fly.

How would you use it? I am very curious, if you have ideas, please let me know.
As always, I hope I have given you some interesting ideas and I wish you a good start to the week!
Happy Coding! 0_1

Top comments (0)