Incus and programming

InternetCitizen2@lemmy.world to Programming@programming.dev – 16 points –

So I am not a professional programmer, but I do like to tinker with projects and just teach myself stuff (in python and now rust). I currently just install stuff on my linux distro off of the repos or anaconda for python. I've never had any particular issue or anything. I was thinking about maybe moving projects into a container just so that they are more cleanly separated from my base install. I am mostly wondering about how the community uses containers and when they are most appropriate and when they are more issue than they are worth. I think it will be good for learning, but want to hear from people who do it for a living.

9

For Python, I find venv is usually fine. When it's not enough, there's pyenv.

For about everything else, I use podman.

I usually use nix to manage my development environments.

At the root of the git repo for my blog, there is a shell.nix file. This file, shell.nix, declares an entire shell environment, giving me tools, environment variables, and other things I need. I just run nix-shell while in the same directory as the shell.nix file, and it creates that shell environment.

There are other options, like VSCode has support for developing in a docker container (only docker, not podman or lxc).

I think lxc/incus (same thing) containers are kinda excessive for this case, because those containers are a full linux system, complete with an init system and whatnot. Such a thing is going to use more resources (ram, cpu, and storage space), and it's also going to be more to manage compared to application containers (docker, podman), which are typically very stripped down and come with only what is needed to run the application.

I used to use anaconda, but switched away because it doesn't have all the packages I wanted, and couldn't control the versions of packages installed very well, whereas nix does these both very well. Anaconda is very similar in usage though, especially once you start setting up multiple virtual anaconda environments for separate projects. However, I don't know if anaconda is as portable as nix is, able to create an entire environment from a single file of code.

Thank you for your thoughtful reply, but does nix package manager need to be using NixOS?

It doesn't, you can install it on mostly any Linux distro

Simplest way in my experience is distrobox. It will automatically spin up a container (podman or docker depending on your distro) for you with a fresh OS. Go ahead and install whatever without touching your main install, spin one up for each major project and one for scratching around. Instructions only available for Arch or Ubuntu, no problem. One gotcha, make sure they have their own homes, or you'll get junk in yours...

I love containers for this use case.

They allow you to just install and test pretty much anything you want and if it doesn't go well... just rebuild the container and start again. Rebuilding a container takes about 5 seconds to fix problems that would take 5 weeks of headaches if you made the same mistake on your main operating system.

If apt-get install wants to install a bunch of dependencies you're not sure about, oh well give it a try and see how it goes. That's definitely not an approach you can use successfully outside of a container.

Another benefit of containers is you can have two computers (e.g. a desktop and a laptop) and easily share the exact same container between both of them.

Personally I use Docker, because there are rich tools available for it and also it's what everyone else I work with uses. I can't speak to wether or not Incus is better as I've never used it.

The more reliable/reproducible the container is the more pain/effort it is to setup. If you don't need reliability, then you don't need containers.

  • If you want unbeatable reliability, use nix.
  • If you want better-than-nothing use venv/anaconda envs (one or the other, not both)
  • If you want the most reliability-per-effort and don't care about performance, use distrobox
1 more...