Search code examples
nixnixosnixops

What is the common way to install utility programs like file and ripgrep in NixOS


I want these programs to be installed in my user environment while not using nix-shell and nix-env (I was told to not use nix-env). I tried to use home-manager but I can't do program.file/ripgrep bc it's not an option. May I ask what is the common approach to install things like file and ripgrep in NixOS?


Solution

  • With home-manager, you can install programs by adding them by adding them in home.packages. For instance, if you want to install ripgrep, you could add in your home.nix:

    home.packages = [
      pkgs.ripgrep
    ];
    

    Or, more conveniently

    home.packages = with pkgs; [
      ripgrep
    ];
    

    You can add any program you want in that list.


    Note that there is a difference between installing them with home-manager, and by adding it in environment.systemPackages, which is that the former will only install them for the user, while the latter will install system-wide. Besides that, both work similarly.