tldr
A fully working setup to begin your NixOS development. It'll get you running immediately so you can just focus on developing your own nix while running it with quick local files to reference.
1. install nixos from iso.
2. nix-env -iA nixos.vim nixos.git
3. git clone https://github.com/dfosterj/nixos-template to /etc/nixos/nix
4. make backup of /etc/nixos/.nix files then edit configuration.nix by removing all conf lines besides boot. and adding path to flake dir to imports. (See github ReadMe for more explanation and examples)
5. review hardware templates in ./hardware dir, create new or edit the matching workstation.
6. run bash setup.sh to create variable file /etc/nixos/host-variables.nix or manually create (see github readme for example).
Important setup note:
Workstation name must match with corresponding common hardware file at ./hardware/workstationName-hardware-custom.nix
If wanting to use a personal dotfile repo, while developing your nix setup copy your repo to ~/.dotfiles/config and uncomment the systemd_custom_dotfile.nix import in configuration-custom.nix. This is a process that'll link your files for live system use.
enjoy and start using nix!
Intro
NixOS is amazing, but can be a daunting task to learn and write all your customization. I'm offering my take on a NixOS structure to help anyone interested in testing it out, or getting started on their own. This template is a snapshot mid-journey of my migration. It is a fully working setup and can be used as a daily driver as is. Simply install nixos, clone the repo, run setup.sh or create the host-variables.nix manually, build and switch to the flake thats it!.
Whats included?
This setup uses flakes and home-manager. Its setup to handle multiple workstations by using a variable, which points to a hardware conf located at ./hardware. There you'll see templates for a basic laptop or desktop, and a nvidia gaming desktop with controller support.
There are number system pkgs found at nix_modules/pkgs.nix and a few user apps found at nix_modules/flatpak.nix. The system pkgs include support for multiple desktop environments, and developer tools. The idea was to have user specific apps isolated as flatpaks.
At this time, the vim and neovim setup simply enables the program, and installs support for their native building tools such as lazyvim, and vundle.
There are a few dotfiles already written located at ./home/home_modules.
Importantly, there is also a systemd service that'll mount the path you declare as a variable during setup script to your users's .config/ to bring live to the system. This is assuming you have your dotfiles in a repository already. This service can be found at ./nix_modules/systemd_custom_dotfiles.nix. To use, place your dotfile repo at ~/.dotfiles/config and uncomment the systemd nix file in imports section of configuration-custom.nix
For desktop environments, It comes configured with Gnome, KDE Plasma, Hyprland, and my favorite BSPWM. It does not come with configurations for hyprland or bspwm. You'll have to bring your own.
If you wanted to use my dotfiles for bspwm (pictured on top of page) or hyprland WIPs they can be found on my github here..
https://github.com/dfosterj/bspwm-wip
https://github.com/dfosterj/hyprland-wip
https://github.com/dfosterj/polybar
Dir Tree
A quick tree view of the structure.
├── configuration.nix
├── hardware-configuration.nix
├── host-variables.nix
└── nix
├── configuration-custom.nix
├── flake.lock
├── flake.nix
├── hardware
│ ├── laptop-hardware-custom.nix
| ├── desktop-hardware-custom.nix
│ └── nvidia-desktop-hardware-custom.nix
├── home
│ ├── desktop_files
│ ├── dotfiles
│ ├── flake.nix
│ ├── home.nix
│ └── home_modules
├── nix_modules
│ ├── flatpak.nix
│ ├── picom.nix
│ ├── pkgs.nix
│ ├── systemd_custom_dotfile.nix
│ └── unstable.nix
├── README.md
└── setup.sh