4 ms·
That works for a temporary development environment in e.g. shell.nix. But what about the global environment?
by gpanders 5y ago
That works for a temporary development environment in e.g. shell.nix. But what about the global environment?
- xfer 5y agoUse nix-env -i . But i would suggest using home-manager instead.
- takeda 5y agonix-env -i -f '<nixpkgs>' -E 'f: (f {}).python3.withPackages (ps: with ps; [pyyaml requests])' But you don't want to install globally. One of major strengths (for me at least) is that when combined with nix-shell you have something like virtualenv, but for all packages, not just the ones from python. This means that someone else who checks out your project can get the same environment you had for the development. If this is combined with direnv, then you don't even need to invoke nix-shell you just enter the project directory and everything is there. If you use something like poetry2nix[1] it will automatically have the dependencies your project has. [1] https://github.com/nix-community/poetry2nix https://github.com/nix-community/poetry2nix
- gpanders 5y ago> But you don’t want to install globally. I do want to install globally, as outlined in my original comment. Unless you can tell me how to somehow modify the installation of Weechat to also include this one Python package. I think Nix is a really cool concept and no doubt there are certain use cases that it solves really well. But my experience with it as a day to day package manager was that it just made simple things hard without a proportional benefit to make all the trouble worth it.
- takeda 5y ago> I do want to install globally, as outlined in my original comment. Unless you can tell me how to somehow modify the installation of Weechat to also include this one Python package. The goal that Nix tries to solve, is to make all implicit dependencies explicit. The proper way of doing is to list these packages in the WeeChat. Anyway I never used it myself, but looks like nixpkgs has dedicated section for it: https://nixos.org/manual/nixpkgs/stable/#sec-weechat https://nixos.org/manual/nixpkgs/stable/#sec-weechat > I think Nix is a really cool concept and no doubt there are certain use cases that it solves really well. But my experience with it as a day to day package manager was that it just made simple things hard without a proportional benefit to make all the trouble worth it. Yes, it indeed it makes simple things hard, but then this approach makes hard things easy. Because every package in Nix repo have explicit dependencies it solves many other problems. You no longer have dll hell for example a project that uses nix to build, generally just builds without issues. I use Nix for development and the great thing is that I can use it to describe all tooling that I need for development. So another person can replicate the same environment. I was able for example to write a custom modules to standardize dev environment. And if someone uses it I can easily use the same mechanism to produce: - nix package - wheel package (it is for Python project) - package application into docker with just only the necessary pieces (can also slim python by only compiling features that are actually used) When using nix for building, I can speed up the work, because Nix only rebuilds things when things change. For example in traditional pipeline when you work on dev branch when you merge branch it typically rebuilds the whole thing. Nix is smart, and tracks what actually changed. If no actual files changed the build will return immediately with the binary that was produced on the branch. If during the merge our branch was integrated with some other changes that happened in the master branch, Nix will know to rebuild it again. In addition to that, on average built time was cut in half for me.
- pxc 5y ago> Unless you can tell me how to somehow modify the installation of Weechat to also include this one Python package. pkgs.weechat.override { extraBuildInputs = [ pkgs.python3Packages.pync ]; }; }; That Nix expression defines a package meaning 'just like Weechat, but with pync in the build paths'. There are examples with links to more docs on the unofficial NixOS wiki: https://nixos.wiki/wiki/Weechat https://nixos.wiki/wiki/Weechat Looking at the Nixpkgs docs, you might prefer a different override expression. Several examples are provided: https://nixos.org/manual/nixpkgs/stable/#sec-weechat https://nixos.org/manual/nixpkgs/stable/#sec-weechat I understand that this may still feel like 'making a simple thing hard', but it does, I hope, answer your question. Modifying existing packages in just a few lines of code in order to include additional dependencies is very much part of Nix's paradigm. :) There's a way you could write all that inline to install it with nix-env, too, but I can't be arsed.
- gpanders 5y agoThanks. I am not sure how I missed that section in the manual that answers my exact question… I will give that a try!
- pxc 5y agoNo problem! Once you apply the override concept with Weechat, you'll have a feel for what is a very general suite of customization mechanisms in Nixpkgs. That'll be unlikely to miss a similar opportunity with other packages. NixOS Discourse is a great place to clear stumbling blocks like these, by the way :) https://discourse.nixos.org https://discourse.nixos.org
- gpanders 5y agoThis worked! Although I ran into another problem with pync itself, which led me to open my first PR with nixpkgs [1]. Thanks for convincing me to give it another shot! [1]: https://github.com/NixOS/nixpkgs/pull/130402 https://github.com/NixOS/nixpkgs/pull/130402