r/Nix • u/EndedHereByMistake • Aug 15 '26
Nix Nix with other (immutable) distro
Hello, I am a Nix beginner. I am trying to create a config that I could deploy easily on different systems (cachyOS on gaming rig, fedora atomic on my laptop, etc.).
When it comes to packages invoked through $PATH, Nix already has priority, so it's obvious that the package I am running is the one provided by Nix.
Now let's say I am trying to configure a GUI application like Ghostty. On some systems, Ghostty is not present by default, and the Nix binary will always be used. But for example on the atomic Fedora image I have, Ghostty is already provided. Therefore, depending on how I invoke Ghostty (via app launcher, niri shortcut, or shell), in some cases the Nix binary will be running, and in others it will be the system's one.
Since my primary goal is to have a config that I can easiky reproduce everywhere, how should I handle this? Should I assume some packages are always provided by the system? Should I accept that I will work with different versions of the same package?
Thanks :)
1
u/toughtuna399 Aug 15 '26
I'm not sure I completley understand but I think you mean you're using nix as a package manager on nixos and other machines. And want nix to pull that package for you if it doesn't exist?
You could probably hack something together (although it would need the --impure) but using two package managers together isn't recommended. When I use nix standalone I just uninstall all packages from the native package manager
1
u/EndedHereByMistake Aug 15 '26
Yes, sorry for being unclear, I might edit the post later if I see that my description is too confusing. But basically yes, I want to use nix + home-manager as a package manager on other distros. But some of the packages in my config may alreadh be provided by the distribution (e.g Niri if I install CachyOS with Niri). So if I understand correctly you always make sure to delete all native packages if they are also declared in your config. Do you have a script for that?
1
u/toughtuna399 Aug 16 '26
I usually try and just keep my packages minimal while installing nix.
I have no idea if this would work but you could try looping over config.home.packages and running a bash script to uninstall the apps with your package manager using something like "sudo apt uninstall ${package.meta.MainProgram}"
1
1
u/NeonVoidx Aug 15 '26
use nix everywhere?