[solved]Need suggestions using third part pkg manager on nixos

I need a tool on rubygems which isn’t on nixpkgs, and it is not a lib or something for a project but for myself to help coding. It depends on some system libraries such as libxml. So I cannot install it simply by gem which complains about link error. What is the best way to do it? Must I write a overlay or custom package to build them? Or are there some simple way to make lib installed globally can be automatically added into link path or relative variables.

Can you tell us the name of the gem?

Not for a special gem,and not only for ruby. If I want to install a pkgs on npm, use npm or package it into nixpkgs? Or is there a better ways?
I want to manage all tools from a package manager in the same way, not some in nix and others in third part manager.

Well, I’m asking because the answer will be Ruby specific. See NixOS - Nixpkgs 21.05 manual for a bit more info, but it boils down to writing an expression that uses bundlerApp and a file generated from bundix.
The other option is to use a buildRubyGem derivation, but that won’t handle any dependencies automatically.

If you don’t want to actually package something for others, you probably want to use nix-shell. You can for example start with this:

with import <nixpkgs> {};
mkShell {
  buildInputs = [ libxml2 ruby bundler ];

And then either manually use nix-shell or something like http://direnv.net/ with a use nix directive to get a shell that has those dependencies. Then execute bundler inside of it.

Globally installing libraries is not something that works on NixOS, but using language-specific package managers inside of a nix-shell can work for most cases and is something I sometimes do for development as well.

1 Like

Thank you. I spend a day to read all document on nixos and wiki again. Now I know what I should do and why I should do.