As a relatively novice user, I installed NixOS for the first time on my laptop at the beginning of December. I began tracking my configuration.nix in early January and just kept adding app names to the the package list as I went along. It was total chaos until today when I sat down and refactored it. At the bottom of this post is a link to two different configurations - - one is the commit before the refactor and the second is the commit snapshot after the refactor.
While my new setup is not truly modular I reorganized all the package names under different taxonomical categories indicated by blank lines and then a comment. I managed to pull this off by using Neovim, my keyboard, and a tiling compositor - - no mouse or floating window managment required.
I am making progress. I am not asking for a pat on the back. Instead my ask from all of you is for feedback on how I could make the latest iteration of my configuration.nix even better. How would you people recommend I optimize it? What advice would you give?
I am accepting PRβs!
Flakes is too big of a next step. ryan4yinβs terrific Flakes Book has a section on modularizing a Nix setup but I find it too integrated with Home Manager to be of any use to me at this point. I am staying away from Flakes after having a bad experience when I started following ryanβs guide and practically wrecked my system for weeks.
Here are the two different configuration.nixβs for you folks to compare:
Hello
Your config is looking good. Especially that your packages are all that neatly organized.
But there are some things you can still do.
First of all you can write your config in different files. For example one with your packages, one for your boot config, etc.
For that create a new file like systemPackages.nix and at the start of that file put in this:
{config,pkgs,lib,inputs,...}:
{
#config
}
Than you can just import them in your configuration like the hardware-config in the import option.
With that you have a nicer overview over your system. Especially if you add more your config will still be readable.
For example my /etc/nixos looks like this:
The programms directory is for my home-manager. All the configs in there are imported by my home-manager.
The png directory is for my background (currentyl a video).
The scripts directory is for scripts.
The system directory is for my configs that are imported by my normal configuration.nix.
The second thing i recommend you doing is Flakes and home-manager. I know that these a a bit complicated for a beginner, but really pays out in the long run. The best feature of flakes is, that it locks your package versions. Means if you setup your config on another machine all the versions will be the same. Also you than donβt need to use channels anymore, which for me are a bit annoying.
Home-Manager is really great when configuring programs like bash, kitty, etc. They offer you much more options to customize your system. Especially with hyprland.
A great source to get started is the series by Vimjoyer:
The third thing I can highly recommend you doing is stylix. For stylix you donβt necessarily need a home-manager. But for customization it is just fabulous. Vimjoyer also did a video on that.
I tried home-manager and I completely borked my system. It took me weeks of troubleshooting with other forums members here. In some places it was like the blind were leading the blind. Nix shell tracebacks are so esoteric and aribtrary that it is not always clear what the true issue/solution is, even for experienced users and Linux veterans.
I resolved to falling back to a vanilla NixOS nixpkg tools (for now).
If this is true, here is my proposition: How about I successfully migrate both my computers (laptop and a tower) from Manjaro to NixOS with nixpkgs and then set up a virtual machine on my tower (with 64 GB of ram and UQHD monitor) and experiment with flakes and home-manager. If it really is so easy to transplant one configuration on one machine and reproduce the exact same package setup on another, then I should be able to experiment and learn flakes and home-manager in a VM and then clone that flakes/home-manager repo and deploy to my laptop and tower PC natively after I come up with a satisfactory setup virtually. It really should be that easy, correct? This is not a rhetorical question. I am looking forward to your response here @Postboote.
Last week when I read your comment for the first time, I checked out that YT video. I have seen some of Vimjoyerβs videos in the past. It is indeed some high quality YT Linux content. But today when I sat down to review your comment a second time, I see you shared Vimjoyerβs playlist which I tallied up and runs for four hours and forty five minutes! Itβs a smorgasbord. Iβll get around to watching all this content. Thank you for sharing this extended YT playlist.
I am in the process of styling each app (CLI and GUI), one at a time using Catppuccin - - just the ones I need. I have a few dozen apps. I am storing the configurations in dotfiles and managing them with GNU Stow. I realize that most of the heavy lifting here can be achieved by automating the theming using flakes like by using this repo / project here. But I am not ready for that yet.
I canβt remember now where I read this, but I was reading tech news or a blog a few weeks ago. It might have been on the Phoronix forums. The author / member conveyed that experienced developers who have degrees in computer science and who work in senior software positions who write C++/Java/Rust for a living, look back and say things like: βOh, Python syntax is like pseudo codeβ or βSQL statements are just as easy to understand because itβs almost as natural Englishβ. But the truth is, when students are brand new to computer science and are learning their first language, Python is not easy to understand at all and writing SQL statements is not obvious. I really messed up my NixOS system when I jumped into flakes too soon. Home-manager is biting off WAYYYYYYYYYYY more than I can chew. Flakes is like learning to run before you can walk. I will get there. I am determined that I will. But not today. I have resolved to stick with nixpkgs for now. Exercising the full power of NixOS takes years of practice and has a learning curve much steeper than Arch and Gentoo. What I am trying to say with all of this @Postboote, I find your insistence for a novice like me to learn flakes and home-manager to be tone-deaf. As much as I appreciate sharing Vimjoyerβs playlist and all the advice, pitching flakes and home-manager is a little bit misplaced.
Yeah that should totally work. In my Experience it is best for beginners to first start in a VM. You can always fall back to your normal machine if you brik your system. If you use flakes in your VM and thereby lock your package Versions, you can just put the lock file on you laptop or your regular PC and have the same versions. In the future you could go even further and try using one Config on both of you machines, but for now having them separated is enough.
That is completely fine. I first started with flakes after like 6 months after I started my journey with Nixos. After that I started using home-manager. Now I do not think that I would use Nixos without them. But you are right. Learning flakes and Home-manager can be really hard. Especially if you have just started you journey. Just learn them in your speed.
I am sorry that I brought it across this way. What I meant was that you should try these if you are ready to.
Itβs been about 2 weeks since my last comment. I am back to finish my thought!
Not sure if an apology is warranted although I appreciate your sincerity.
This is what I was referring to:
From the official README.md for home-manager:
Unfortunately, it is quite possible to get difficult to understand errors when working with Home Manager. You should therefore be comfortable using the Nix language and the various tools in the Nix ecosystem.
If you are not very familiar with Nix but still want to use Home Manager then you are strongly encouraged to start with a small and very simple configuration and gradually make it more elaborate as you learn.
Easy does it. I am determined to start small. Iβll get there.
NixOS has been around since 2003 but flakes is only about 5 years old (if I understand correctly). So NixOS should be able to stand up on its own feet with nixpkgs alone and then add flakes as I go along.