zoey1771
zoey1771

Reputation: 119

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?

Upvotes: 2

Views: 969

Answers (2)

jthulhu
jthulhu

Reputation: 8678

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.

Upvotes: 2

Chris Stryczynski
Chris Stryczynski

Reputation: 33921

You should be able to set this in your nixos config:

environment.systemPackages = [
  rigrep
  file
];

I have no experience with home-manager so I don't know how it compares, but you should surely be able to install ripgrep with it.

I've been using nix-env for years without issue, only negatives is it's harder to keep track of things. But works fine for things you want to install 'temporarily' to have them available in your $PATH without having to invoke nix-shell.

Upvotes: 1

Related Questions