How to Start Adding Modularity to your NixOS Config
ฝัง
- เผยแพร่เมื่อ 2 ธ.ค. 2023
- Join as a Channel Member:
/ @librephoenix
Join Liberapay: liberapay.com/LibrePhoenix/do...
Join Patreon: / librephoenix
This video will give you a few tricks you can use to make your configuration more modular. In specific we talk about separating your NixOS config into multiple files (modules) and selectively importing them using the imports list in your configuration.nix and/or home.nix.
Associated Blog Post: librephoenix.com/2023-12-03-m...
Links referenced:
Nix Language Basics (nix.dev): nix.dev/tutorials/nix-language
MyNixOS: mynixos.com/
My configuration (if you're curious):
GitHub: github.com/librephoenix/nixos...
GitLab: gitlab.com/librephoenix/nixos...
Codeberg: codeberg.org/librephoenix/nix...
Wallpaper backgrounds were found on freepik.com. - วิทยาศาสตร์และเทคโนโลยี
This is the most helpful nix video I have come across to date. I really appreciate you explaining what the syntax actually means. I hadn't understood that the contents of squiggly brackets were attribute sets, and just that one piece of knowledge made so many things click for me. Please keep up the good work, I'm eagerly awaiting your next video.
x2!
I have rage-uninstalled NixOS a couple of times but always been drawn back… This time I found your video series which is very helpful! Please continue!
Definitely! I'm glad you're finding the series helpful! :)
Me too, took me a few months of really hunkering down for it to eventually click. Very different from any traditional distro, although it's pretty much all I use now
I started watching this series when I finally decided to take NixOS for a spin last night. This one came out right in the nick of time and is answering a lot of my questions. From what I've seen, I think you are currently producing *the* best NixOS intro video series available. Keep em coming, and thanks! Where's your Patreon lol
Again, thank you for the detailed value rich content. You're a true asset to the Nix community
Thanks! Glad you're finding the videos helpful!
Amazing! Not only do you know the subject matter well but you are able to teach it in a digestible manner.
your series is amazing
I have been loving this video series! This video was particularly good. Can’t wait for the next one!
One of the best vídeos around. Great explanations!
Really amazing and helpful content, carry on
Great vids! I was thinking of switching from NixOS after a few months of using it, cause I was having some issues and not eough time to research and fix them, but your vids have made me want to start tweaking my system again and learn more about it.
This is fantastic introductory content. You have a nice and clear presentation style too 👍
Excellent video!
Great video! Really looking forward to the hyprland + nix video!
love it! thank you!
This is one of the best NixOS related videos I've seen so far, great job man!
Best nixOS playlist "guide" I ever seen. Thanks a lot for your effort
This is just the video I needed. Answered many questions I've had trying to learn Nix these last couple of weeks. I appreciate it greatly.
Appreciate the efforts man, also your github configuration is very readable, systematic and well documented, massive props mate :)
Great video. Going through the syntax was helpful
Absolutely fantastic intro series, thank you! The docs are hit and miss at best, but your videos are just fantastic. Love the way you explain everything. Finished implementing flakes, and home-manager on my test laptop, going to add the rest of the desktops configuration to it as well soon. Well done!
Thanks for the content
Bro you are a God Send! Thank You!!!
Amazing, im new in nixos and easy to understand your explain about nixos, thanks
This is the most helpful nix video thanks Bro
these videos are veeery good. I took a config from a repo and edited a bit to make it mine, but now I'm really starting to understand what everything does, can't wait to watch the rest. Thanks again!
Amazing explanation thanks so much. I may not grasp all of them but the way to describe them in sequence and in details are top notch. You got a new subscriber wanting to learn more of Nix and NixOS. Keep up the good work!
Thank You!
This was a very educational content. Crystal clear. Thanks a lot :)
This is very well done. I will for sure be setting this up on my laptop. I still need fully set up my emacs. Your Doom Emacs looks nice.
Thanks a lot for these videos. I just got into linux and I wanted to start with NixOS because of its capability to be reproduced on other systems easily. Starting with Nix is pretty daunting and i might have changed my mind to go back to some other distro but then i found your channel. Now i am understanding how to Nix and with the upcoming tutorials I might be able to customise my setup atleast somewhat more to my liking.
Thank you very much, your videos are great.
Thanks! Glad you've found the videos helpful!
Amazing, thank you.
Echo mikefdorst Audio - 10, visual clarity - 10, expository clarity - 10, pertinence - 10
16:19 he says the most true thing for my apps
Oh my god I spent so much time not understanding where the "file not found" error was coming from!!! Honestly the one thing NixOS os really lacking is documentation of all sorts. The small warning "you need to stage/commit the file to git to be able to import it" would save me so much time
Just came here to say a massive thank you .... your way of explaining things in your nix videos just clicked for me. Massive thanks!
Secondly..... Why oh why is this not a pinned video on any "beginner" Flakes tutorials ever made!
I'm new to Nix. I got about halfway through the This Cute tutorial and a few others before I got burnt out on configuration and tabled it. TH-cam just suggested this video for me, so I gave it a watch.
One of the things that's been unclear for me is how best to use flakes. As an outsider, it's strange that the literature essentially says "configuration is old and broken; flakes are the new hotness," but also "put your imports in flake and use them in configuration." Managing one thing in two places feels gross.
If configuration.nix is just another module and lists get merged across modules, I can make better sense of it. (Although I still think it's gross that imports go in a different file than where they're used.)
Thanks for putting this together.
Really great video again dude. Can't wait for your next one! Any chance you are going to show doom-emacs config as an example? That one is a bit weird to set up as a newbie
Hi thanks a lot for your videos. They are extremely helpful and very well done.
Can you go over incorporating Emacs config with Nix?
Love this video an all the others in the series - honestly a life saver! great job man, thanks! I have one question, how does the nixos-rebuild switch and home-manager switch commands know to take the hardware-configuration.nix and configuration.nix from you .dotfiles directory and not /etc/nixos?
smooth
Hey!
I find your content very helpful. Could you maybe do a video on your browser?
Thanks! That's qutebrowser, and I'll definitely do a video at some point on it :)
Could you do one more on your emacs & WM setup please?
Helpful video. I found interesting that you call currying weird, a concept I think is a fundamental concept of any functional language, but you don't seem to find the "in" part weird that I haven't seen anywhere else and I find really weird.
Thanks for the great video, Emmet!
It was exactly the kind of video I was looking for. When it comes to tech (or really anything), I get easily overwhelmed. So it comes natural for me to break things down and deal with one thing at a time. Actually, I got quite excited about the "homework assignment". I'll get down to it as soon as I'm over this stupid COVID infection and my brain is working again.
There is only one thing that still confuses me about modularity in Nix. Or maybe I'm getting mixed up. Does "input" always mean "argument to function"? And is there any essential connection between inputs and imports?
Glad you found it helpful! Yeah, I may have said "inputs to the function" and meant the "argument(s)" I'm sometimes a little imprecise with my vocab :P tho arguments to a function definitely relate to the whole idea of input/output. In Nix, inputs can also mean "the sources or source code of a package" which is what inputs mean in a flake.nix
How do you edit the files on the host and they affect the vm?
This thing is like Terraform for Operating systems, the more i look at this.
New to nix, does this mean i can keep configuration.nix in with git version control in any directory i want or do I have to somehow link it to /etc/nixos/configuration.nix?
If you may want to use the same module (say a basic shell utils module) in your nixos config and also might want to use the same module elsewhere (like as a base for nix-shell dev environments on non-nix machines) is there a benefit to keeping that module in its own separate flake and repo? Can flakes be treated the same as modules?
How do you get your errors to be so concise?
What happens if the priority value is the same? Having mkForce in 2 places?
Bruh. Only reason why NixOS is not the most popular is because it's hard to understand. Thanks for breaking it down.
Some more details on why you didn't call it shell.nix would be helpful. Is that something I need to be on the lookout for? Is there a list of other filenames that should be avoided? Would it break something if you called it shell.nix?
Can i use wildcards in imports?
The whole git staging requirement is so opaque, not discussed, and the error message is so elusive that it's astonishing.
I've fully bought into nix and nixos but they need to seriously invest in better error messaging.
First 🎉😂
Can you make a video explaining how to setup emacs using nix?
All my bugs are also features and NOT BUGS! 😂😅
Nice video which visit almost the bare minimum for making use of modules as a way to split the content as you want.
However, knowing that the first line of a module is the function argument is not necessary for using NixOS modules. While this is true, this does not add any value for new users, it just adds extra barriers for learning about modules. Just knowing that the first line has to be there should be good enough for most people until they learn about `_module.args` or `evalModules`.