Hacker News new | past | comments | ask | show | jobs | submit login

> That and the ability to install a package in a shell, use it, then exit the shell and not have it installed globally is amazing.

I can't even count the number of packages I have installed because I needed them once. I have an entire Node.js ecosystem installed because I needed to run a frontend from another team for 20 minutes. Could I have done all that in a single shell, then had it automatically cleaned up when I was done? My current solution is to spin up a container, but that becomes a pain and I end up getting lazy and just globally installing everything again.




> Could I have done all that in a single shell, then had it automatically cleaned up when I was done?

Yes, that is a pretty standard workflow for most nix users. You either set up a shell.nix for your project with all of its dependencies, or if you need a certain tool once you just write for example: ‘nix shell -p iotop’ to enter a shell where iotop is in the path.


Wow, that's pretty great. I'm gonna spin up a Nix VM shortly, see how it goes.


Certainly. You'd be just a `nix-shell -p nodejs` away from being in a shell with NPM. And a C^D away from not having it installed, with a caveat that it would be cleaned up periodically and not immediately after exiting the shell. But I think there's an option for immediately removing after use as well.


Yeah, you can just have a couple of config files and spin up a shell that auto-installs everything. The packages are all on your system, so the next time you start the shell, nothing has to be downloaded, but they're not installed globally, and a you can do a garbage collection command at any time to clean up everything.

When I first started using NixOS I had a huge list of globally installed packages, but that has become smaller and smaller over time. For instance, my main browser is Firefox, which is installed globally, but if I need to use Chrome, then it gets fired up in a temporary shell.


I haven't used it in a while but Vagrant used to be great for "setting this up with apt and the language's package manager would be straightforward, but containerizing it would be a pain" one-offs, to keep it off your base system. And didn't require you to keep an entire image around to do it again, just the vagrant config file.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: