4 ms·
Sure - you're Nixing wrong. Not to worry, it actually takes ages to figure out how to Nix right - there's not enough documentation on the matter. The correct w
by vertex-four 9y ago
Sure - you're Nixing wrong. Not to worry, it actually takes ages to figure out how to Nix right - there's not enough documentation on the matter.
The correct way to get almost anything installed is to write a Nix package, and install that. This is actually remarkably easy in comparison to other package managers - you write the package definition in a single file, normally just having to set the source code location and list its dependencies, and you can make it available to install with nix-env by adding it to a packageOverrides declaration in ~/.config/nixpkgs/config.nix.
The "stdenv" build system that nixpkgs uses will automatically install anything that can be configured via "./configure && make && make install" - cmake is supported just by listing that as a build dependency. Stuff written in scripting languages is more fiddly, but the nixpkgs documentation usually has examples. The downside is that a significant amount of the time, libraries written in scripting languages aren't packaged either, and you wind up packaging half a dozen libraries just to get some tool working. The <X>2nix tools can be useful in these cases to generate a package definition.
- malvosenior 9y agoThank you for the awesome reply (and everyone else). This is precisely the issue I have though: > The downside is that a significant amount of the time, libraries written in scripting languages aren't packaged either, and you wind up packaging half a dozen libraries just to get some tool working. I've gone down this path a few times and days later when I still don't have the original thing I wanted working installed, then I sort of give up. I realize there are many benefits to Nix and I really enjoy them but I've switched to using Arch for practical reasons. I really, really miss the declarative reproducible style though.
- vertex-four 9y agoWhat I wind up doing while developing is just creating a nix-shell with my native dependencies, and using pip/cargo/whatever inside that. It's not the "proper" way of doing things - you wouldn't want to install a tool long-term that way - but it's useful for one-off things or while you're playing around. I've used npm2nix and cargo2nix a couple of times with success - they generate package sets from the relevant sources.
- hollerith 9y ago>you wouldn't want to install a tool long-term that way I'm curious why not. Aren't pip/cargo/whatever suitable for long-term use? Consequently, couldn't nix's upgrading routines be modified to call out to pip/cargo/whatever to upgrade things best upgraded by pip/cargo/whatever? I guess what I want to know is whether the architecture or the philosophy of nix interferes with nix's being modified in the way I just described. (Maybe it is just that nobody's gotten around to doing the implementation work.)
- vertex-four 9y ago> Consequently, couldn't nix's upgrading routines be modified to call out to pip/cargo/whatever to upgrade things best upgraded by pip/cargo/whatever? No. pip/cargo/etc are nondeterministic. Nix packages should not be. Where they are, things often break in bizarre ways. In order to access the Internet, a Nix package must declare the hash of its output - given that pip can produce different output from run to run (it contains a constraint solver which depends on the versions available in the external package repository) this is impossible.
- pxc 9y agoHave you tried using something like `home-manager` (https://github.com/rycee/home-manager https://github.com/rycee/home-manager)? It gives you declarative package and configuration management with Nix on non-NixOS. It might be a nice compromise until NixOS/Nixpkgs is mature enough to meet your needs more completely. Or maybe you'll never switch, if you really like the convenience of being able to easily grab a trendy package from AUR or whatever. But either way, there's a lot of declarative Nix-y goodness you can get on Arch Linux! :-D There's a similar tool for macOS called `nix-darwin`, as well: https://github.com/LnL7/nix-darwin https://github.com/LnL7/nix-darwin