fixes npm

This commit is contained in:
alsaiduq-lab 2025-06-14 12:10:10 -06:00
parent 59d5072b1b
commit 298fcf8f32
2 changed files with 19 additions and 43 deletions

View file

@ -3,57 +3,45 @@
pkgs,
lib,
...
}:
# TODO:bandaid fix for now
let
npmGlobalDir = "/home/cobray/.npm-global";
}: let
npmConf = pkgs.writeText "npmrc" ''
prefix=${npmGlobalDir}
cache=/home/cobray/.npm
init-module=/home/cobray/.npm-init.js
prefix=${"$"}{HOME}/.npm-global
cache=${"$"}{HOME}/.npm
init-module=${"$"}{HOME}/.npm-init.js
'';
in {
options.npm = {
enable = lib.mkEnableOption "System NPM Environment";
};
options.npm.enable = lib.mkEnableOption "system-wide npm environment";
config = lib.mkIf config.npm.enable {
environment.systemPackages = with pkgs; [
nodejs_22
nodePackages.npm
electron
yarn
bun
deno
nodePackages.eslint
pnpm
electron
nodePackages.typescript
nodePackages.prettier
nodePackages.eslint
nodePackages.sql-formatter
nodePackages.markdownlint-cli
nodePackages.stylelint
nodePackages.htmlhint
nodePackages.jsonlint
nodePackages.pnpm
nodePackages.typescript
];
environment.variables = {
PATH = [
"${pkgs.nodejs_22}/bin"
"${npmGlobalDir}/bin"
];
};
environment.sessionVariables.PATH =
lib.mkAfter ":${"$"}{HOME}/.npm-global/bin";
environment.etc."npmrc".source = npmConf;
systemd.user.services.npm-setup = {
description = "Set up NPM user configuration";
systemd.user.services."npm-setup" = {
description = "Install .npmrc";
wantedBy = ["default.target"];
script = ''
if [ ! -f ~/.npmrc ]; then
cp ${npmConf} ~/.npmrc
chmod u+rw ~/.npmrc
fi
install -m600 -D ${npmConf} "$HOME/.npmrc"
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
serviceConfig.Type = "oneshot";
};
};
}