My main branch works thanks much to @TLATER & @NobbZ, but it’s a bit of a mess with all the files and code. I’m trying to simplify it and move to my testing branch, but I’ve hit a snag and my flake doesn’t run correctly because of my code is incorrect. I’m thinking the way I have the machines and users coded is the issue. Hopefully I am on the right track and this can be fixed with a little editing.
My end goal is to get to the point where I can specify a PC and user(s) to my flake & configuration files so that the appropriate packages will be installed on each machine as each user prefers.
Basically, I would like to be able to install nixos on a PC, download my flake from my git site, and be able to build the appropriate derivation for that PC and user. I have a personal desktop, laptop, a server, and some family & friends’ PCs that I would like to eventually have everything consolidated and managed by this set of files. I am currently copying the configuration.nix and hardware-configuration.nix located at /etc/nixos into the appropriate subfolder for each machine in this setup. I’m reached the limit of knowledge and would appreciate any help as I can’t seem to make any more progress struggling through this on my own.
Here is my ‘testing’ branch of git for reference:
Your help is much appreciated and hopefully some like minds will find this topic and benefit as well!
Most of what I have is based on colemickens (Cole Mickens) · GitHub which has gotten more advanced over time too. If I were to make a new general layout, I would probably make more use of the NixOS module system and get rid of the profiles/mixins/ distinction.
Personally I have one big “default” module that configures the things I want all my devices to share, and then I have computer-specific modules for the more specific things. Over time I’ve found keeping things (relatively) simple pays off a lot.
Since I don’t really prepare this for anyone else, the default module also sets up my home-manager configuration.
If I were to add more than just one user to this, I would probably also create multiple home-manager modules, one for each user, and then instead of importing user config in the default module import the correct user modules for the specific computers in their modules.
I make use of the fact that import <dirname> == import <dirname>/default.nix a lot, a newbie might want to be aware of this when reading through my repository.
Edit: Really need to go through and reshuffle what I consider “device specific” at some point x)
Thanks @nixinator! Looks nice and clean. I started to go through your flake.nix and looked briefly at the t480. Will try to clean up my code based on this and will likely be back after the holidays as everything is crazy busy now.
Or am I making to much of a jump because of my already existing home folder location?
I’m trying to keep it simple and create one file that can build both systems. If I understand it correctly I would run : nixos-rebuild switch --flake .#nixos on one PC and nixos-rebuild switch --flake .#newhostname on the other machine to build the appropriate hostname on the appropriate machines. And I could keep my username and home-manger username all the same underneath and each system would build with the global and home-manager packages that I specified.
It took me a while to learn, clean up my configs (at least a little), and get past some other obligations, but I was able to build a separate PC last night using the same flake file. I pulled it from my git site, ran sudo nixos-rebuild switch --flake .#<hostname> and it turned out great!