Hi everyone,
TL;DR: In what ways, if there are any, is it possible for multiple nix configurations be run both simultaneously and in isolation?
When reading about nix, I felt optimistic that it could solve a persistent problem I’m trying to solve, but I so far I’ve had no luck finding a clear answer on the forums. Does anybody know if it’s possible to simultaneously run several configurations or sub configurations independently from each other - as in personal and work related configurations should be kept independent and separate?
I use my computer for different activities (school, work, personal, etc.). I want to produce these environments in relative isolation because each environment contains a theme of packages and configurations that I do not want interfering with the others. For example, if the work environment heavily relies on plasma and the school environment uses river, I do not want plasma settings, configurations, programs, etc. to interfere with the setup for the personal environment and vice versa. Each environment has a different purpose and everything in it is tilted towards that purpose. Additionally, I am trying to get each environment to be completely independent from the others such that if I moved the environment onto another computer it would not stop working because it secretly relied on something another environment provided. I understand this is one of the main selling points of nix?
Currently, I have come close to this goal by creating a directory and shell.nix
file for each environment. Then nix-shell --pure
can be used to switch into it. Setting the home directory to environment directory in the shell file helped to keep the configuration files separate. It’s not easy though to modify and reload the shell environment from within itself without dropping into a subshell. Exiting the shell closes all the open programs in that environment, so that is really not an option either. Also, I cannot figure out how to add plasma to one of the shells.
After trying to use shells as environments, I set up a series of configuration files for the different environments, but I cannot figure out how to get them to work with a multi-user system or when trying to use different environments on different TTYs for example. I feel like I am close to getting everything working, but am missing a small but important piece.
I have looked some into nix profiles, nix shells, nix containers, nix direnv, home-manager, flakes etc., but struggle to get them working in line with my goal - probably because, while I have lots of Linux experience, Nix is completely new to me. I am assuming that nix containers would probably be the most obvious choice, but are there other solutions with less overhead that achieve the same thing? What are my options when trying to use multiple configurations at the same time in isolation using any of these options?
Essentially, the final question is, before I spend days or weeks learning this new system, would anybody be able to tell me if this is possible with nix and perhaps be so kind as to point me in the right initial direction?
Thank you for your help.