Because of NPM I can't use NixOS, Does that mean I can't just install the package manager and home manager on my non NixOS system?

I’ve got NixOS in a VM currently. I almost had it all setup and was getting ready to install Home Manager and Flakes. But, I learned you can’t really use NPM. If you can, you got to go through hoops/extra steps. I don’t want to do that. In my mind, that means it’s broke. Sad, cause I absolutely love nix.

Can I use the nix package manager and home Manager and maybe even flakes by themselves on my none NixOS system or will NPM still not work?

I’m assuming, just by installing nix, it’ll “break” it.

IMO that means npm is broken. IIRC the biggest reason you can’t just use npm on nixos is because of how many packages include prebuilt binaries, which is an insane and awful practice to begin with. Also I believe you can’t do npm install -g because that’s just not how package management on nixos is meant to work; it’ll try to install things to its own /nix/store path which is wrong. Honestly, that’s also a problem with npm, not nix.

No. Npm on another distro will work fine with nix installed too.


So, on my Ubuntu system … I can install the nix package manager and maybe even home manager and use them find? Cause, that would be super amazing. That was the potatoes I wanted. NixOS was the gravy ontop. But, I’ll be more than happy with just the potatoes.

I also agree, that NPM is … well ya … It’s not broken. Alone, NPM is “fine”. I also don’t think nix has any issues either. I just meant … they fight with each other. If I can’t say npm i, npm init, npm start, etc … like I’ve done in the past, I don’t want to change. Don’t want to go through extra steps. If it was just copying a file into the project directory or something that takes 2 seconds … then ok. I have a bad attitude.

Yes. There may be some hoops to jump through here and there to get home-manager to work fully, though.

Using npm on NixOS is also totally feasible, nix-ld solves like 90% of the “fighting”.

Depending on what exactly you want to use npm for, YMMV if you’re not willing to learn what is going on under the hood or even just ask specific questions, though.


I use npm with a bunch of language servers and I leverage npm’s prefix setting:

> npm config set prefix "${HOME}/.cache/npm/global"
> mkdir -p "${HOME}/.cache/npm/global"

After this I can run npm install -g <pkg> as usual.

1 Like

On NixOS? Everything else work, like npm init and stuff? Or you just mean, if I use stand-alone nix-env, home manager, and flakes on my Ubuntu?

Side Note: Just in general, I like the idea of setting up the global cache like that. Genius.

1 Like

I run it in full NixOS, haven’t done an npm init in a while but AFAIK that only affects the local directory so it should work.

The issue with NPM in my experience is the global install which wants to write to the nix directory. Having the global NPM in the user dir makes more sense IMO.

You might need to update your $PATH to have access to globally installed commands as well.

Thank you. I’ll keep that in mind Right now, I’m trying to setup nix, home manager, and flakes up on my Ubuntu system. Trying to get it to build .bashrc, .profile, and .Xresources files like my current ones. Also i3 & polybar configs. Then, gotta figure out how to pull files from a git repo … Like the “System San Franciso Display” font(s) & copy them into the local share fonts folder. You know, things, not in a package. etc…

Once everything is good, I’ll replicate all that in my Nixos VM, and add git hub config support.

After, that alll works, I can make a USB stick and wipe my system out & be on bare metal with it.

yes anything that can be fixed with nix-ld will also usually just run if using nix and home-manager outside of nixOS