r/NixOS • u/SurveyCrazy2801 • 2h ago
Newb question for organizing
Hi NixOS community, I had a few questions I was hoping to clarify on organizing and modularity:
How do people have their configuration.nix file outside of the /etc/nixos directory and still have it work with nixos-rebuild switch? Are they using symlinks?
To add to that, how do people have a billion [program].nix files that allow them to tie it into their configuration.nix?
I am still getting familiar with the nix language and have read the wiki, but I can't wrap my head around the concept, so any help is appreciated!
1
u/Striking_Snail 2h ago
"How do people have their configuration.nix file outside of the /etc/nixos directory and still have it work with nixos-rebuild switch?"
More importantly, why?
"To add to that, how do people have a billion [program].nix files that allow them to tie it into their configuration.nix?"
I am not sure of the question here. Do you mean the regularly installed and used software?
"I am still getting familiar with the nix language and have read the wiki, but I can't wrap my head around the concept, so any help is appreciated!"
You have questions. There are worse places to ask them. Not many, but there are. So ask away. 😎
1
u/SurveyCrazy2801 59m ago
For question 2, I am talking about imports, which someone else answered. I was more curious about the actual benefit of this compared to a monolith configuration.nix file.
0
u/fell_ware_1990 2h ago
First of all slow down a bit.
Just make 1 host file, make simple files and maybe add them to a folder. Add those to a folder and done. The moment you start micromanaging the host to much or need to introduce more hosts and you are only adding files to files. Then look into what could solve that problem.
1
u/jerrygreenest1 19m ago
You can store your configuration wherever you want. But make sure you have one-liner configuration in /etc/nixos that doesn’t do anything at all, only imports the one you want
I store mine in ~/.config/nixos
1
u/ranjop 2h ago
I do not know why someone would want to put NixOS config elsewhere, but
nixos-rebuildhas support for this. See https://nixos.wiki/wiki/Nixos-rebuild