mirror of
https://github.com/nix-community/home-manager.git
synced 2026-09-15 03:09:21 +00:00
64 lines
1.7 KiB
Nix
64 lines
1.7 KiB
Nix
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/pnpm/default.nix
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) mkIf mkOption types;
|
|
|
|
cfg = config.programs.pnpm;
|
|
|
|
# https://pnpm.io/11.x/settings#storedir
|
|
defaultPnpmHome =
|
|
if config.xdg.enable then
|
|
"${config.xdg.dataHome}/pnpm"
|
|
else if pkgs.stdenv.hostPlatform.isDarwin then
|
|
"${config.home.homeDirectory}/Library/pnpm"
|
|
else
|
|
"${config.home.homeDirectory}/.local/share/pnpm";
|
|
in
|
|
{
|
|
meta.maintainers = with lib.maintainers; [ typeparameter ];
|
|
|
|
options = {
|
|
programs.pnpm = {
|
|
enable = lib.mkEnableOption "{command}`pnpm` user config";
|
|
|
|
package = lib.mkPackageOption pkgs "pnpm" { nullable = true; };
|
|
|
|
pnpmHome = mkOption {
|
|
type = types.str;
|
|
default = defaultPnpmHome;
|
|
defaultText = lib.literalExpression ''
|
|
if config.xdg.enable then
|
|
"''${config.xdg.dataHome}/pnpm"
|
|
else if pkgs.stdenv.hostPlatform.isDarwin then
|
|
"''${config.home.homeDirectory}/Library/pnpm"
|
|
else
|
|
"''${config.home.homeDirectory}/.local/share/pnpm"
|
|
'';
|
|
example = lib.literalExpression "\${config.home.homeDirectory}/.pnpm";
|
|
description = ''
|
|
The pnpm home directory. This sets {env}`PNPM_HOME`, which controls
|
|
the default locations of pnpm's package store, globally installed
|
|
packages, and global executables.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home = {
|
|
packages = mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
sessionVariables = {
|
|
PNPM_HOME = cfg.pnpmHome;
|
|
};
|
|
|
|
sessionPath = [ "${cfg.pnpmHome}/bin" ];
|
|
};
|
|
};
|
|
}
|