fixes npm (for real)
This commit is contained in:
parent
ebadab59f6
commit
0003663a8c
3 changed files with 26 additions and 24 deletions
|
|
@ -7,10 +7,8 @@
|
|||
if [ -d "$HOME/.cargo/bin" ]; then
|
||||
export PATH="$PATH:$HOME/.cargo/bin"
|
||||
fi
|
||||
if [ -d "$HOME/.npm-global/bin" ]; then
|
||||
export PATH="$PATH:$HOME/.npm-global/bin"
|
||||
fi
|
||||
'';
|
||||
|
||||
environment.variables = {
|
||||
EDITOR = "nvim";
|
||||
VISUAL = "nvim";
|
||||
|
|
|
|||
|
|
@ -5,43 +5,47 @@
|
|||
...
|
||||
}: let
|
||||
npmConf = pkgs.writeText "npmrc" ''
|
||||
prefix=${"$"}{HOME}/.npm-global
|
||||
cache=${"$"}{HOME}/.npm
|
||||
init-module=${"$"}{HOME}/.npm-init.js
|
||||
prefix=${"$"}HOME/.npm-global
|
||||
cache=${"$"}HOME/.npm
|
||||
init-module=${"$"}HOME/.npm-init.js
|
||||
'';
|
||||
in {
|
||||
options.npm.enable = lib.mkEnableOption "system-wide npm environment";
|
||||
|
||||
config = lib.mkIf config.npm.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
nodejs_22
|
||||
nodejs_23
|
||||
nodePackages.npm
|
||||
yarn
|
||||
bun
|
||||
pnpm
|
||||
electron
|
||||
nodePackages.typescript
|
||||
nodePackages.prettier
|
||||
nodePackages.eslint
|
||||
nodePackages.sql-formatter
|
||||
nodePackages.markdownlint-cli
|
||||
nodePackages.stylelint
|
||||
nodePackages.htmlhint
|
||||
nodePackages.jsonlint
|
||||
];
|
||||
|
||||
environment.sessionVariables.PATH =
|
||||
lib.mkAfter ":${"$"}{HOME}/.npm-global/bin";
|
||||
|
||||
environment.etc."npmrc".source = npmConf;
|
||||
|
||||
systemd.user.services."npm-setup" = {
|
||||
description = "Install .npmrc";
|
||||
systemd.user.services.npm-global-dir = {
|
||||
wantedBy = ["default.target"];
|
||||
script = ''
|
||||
install -m600 -D ${npmConf} "$HOME/.npmrc"
|
||||
mkdir -p $HOME/.npm-global/bin
|
||||
chmod u+rwx $HOME/.npm-global
|
||||
'';
|
||||
serviceConfig.Type = "oneshot";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.npm-setup = {
|
||||
wantedBy = ["default.target"];
|
||||
script = ''
|
||||
if [ ! -f ~/.npmrc ]; then
|
||||
cp ${npmConf} ~/.npmrc
|
||||
chmod u+rw ~/.npmrc
|
||||
fi
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue