With nixos can I install a nodejs package globally?

Viewed 582

Say I'd like to install @squoosh/cli, this package is mentioned in nixpkgs here. Is there a way to specify the package in configuration.nix, or in the home-manager, to have it be installed by nixos-rebuild?

1 Answers

Yes, the packages in node-packages.json appear in pkgs.nodePackages.

In NixOS, you can add it as follows:

{ pkgs, ... }: {

  # ...

  environment.systemPackages = [
    pkgs.nodePackages."@squoosh/cli"
  ];

}

In Home Manager it's similar, but home.packages instead of environment.systemPackages.

Related