5 ms·
I have been gradually moving from asdf to nix shell plus direnv combo. It handles system level dependent packages in addition to programming language version. P
by ananthakumaran 4y ago
I have been gradually moving from asdf to nix shell plus direnv combo. It handles system level dependent packages in addition to programming language version. Pinning the exact version is not a first class feature as of today, though possible by pinning the nixpkg to a specific commit. Hopefully nix flakes will solve this use case well when it is stable.
- striking 4y agoI've led the implementation of Nix as a dev env at my workplace to pretty good results, but none of us are quite yet willing to touch flakes yet because they're still marked as experimental. Do you have any thoughts on whether or not we might be missing out? Any docs we should be looking at?
- DancerOfFaran 4y agoNix Flakes are stable enough to replace nix-shell and lets you pin versions, so it has a significant reliability advantage. Things get a bit tricker when flakes are paired with home-manager and especially nix-darwin, as the error handling leaves a lot to be desired (opaque errors that are extremely difficult to debug, leaving you with few choices outside of nuking all nix and re-starting).
- striking 4y agoI've been really careful to avoid OS-wide environment management with Nix, as we're on macOS; the only thing I do is `nix-env install direnv` imperatively during our setup script so we can sidestep the need for `nix-shell`.
- okkdev 4y agoI'm using nix with home-manager on macOS and I'm very satisfied. Haven't touched flakes yet tho.
- mplanchard 4y agoIf you’re using something like niv, you’ve got most of what flakes will bring to the table. I’m in the same boat as you, don’t want to have people enable any experimental feature to get the dev environment going. I use flakes for all my personal stuff though, just because it’s easier than adding the niv dependency and because it comes along with using the new command line interface. I also like that flakes let you specify multiple targets in a single file.
- TheAceOfHearts 4y agoWould you consider writing up a tutorial? Or is there any resources you'd recommend?
- striking 4y agoWe're midway through transitioning engineers to it, as well as building stuff on top of it to make for a really great DX. I'll probably write a blog post when the whole env is a little more complete.
- antihero 4y agoIs there a give I to do this easily and is does it work on m1 MacBooks? I love asdf but the idea of what you said sounds great! How painless is it?
- ananthakumaran 4y agoIt does work on m1, you might run into more issues compared to intel based Macs though. I wouldn't call nix painless. It might take some time to figure out the packages required, proper env variables to setup etc. But, once somebody in the team figures out the details, it will likely work for everyone in the team and others don't have to go through same pain. The whole setup is isolated to a single project and will not affect other projects. The setup for a old rails project pinned to a ruby version with few dependencies might look like below let pkgs = import (builtins.fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/c92ca95afb5043bc6faa0d526460584eccff2277.tar.gz"; }) { }; in pkgs.mkShell { nativeBuildInputs = [ pkgs.ruby_2_6 pkgs.shared-mime-info pkgs.mysql pkgs.libmysqlclient pkgs.imagemagick6.dev pkgs.pkg-config pkgs.cmake ]; PKG_CONFIG_PATH = "${pkgs.imagemagick6.dev}/lib/pkgconfig"; FREEDESKTOP_MIME_TYPES_PATH = "${pkgs.shared_mime_info}/share/mime/packages/freedesktop.org.xml"; }
- pxc 4y agodirenv + Nix is a great combo, and once you've gotten going with it there are various options you can use to speed up caching or automatically rebuild in the background on changes. For project environments, flakes don't bring much new functionality to the table. They are a nice new convention that is probably worth learning, and they do bring faster evaluation. But don't sweat it.