There seems to be almost too many tools to manage nix configurations with too many different approaches, each with their quirks and learning curve. Googling this issue was more troubling than it should be!
Therefore I tried to keep things simple and converged on a code organization that I find flexible enough for my current nixos needs without anything more than the standard nix tools.
## Repository layout
Here are the directories inside my nixos repository:
```
├── apps
│ ├── eventline
│ ├── files
│ ├── gotosocial
│ ├── miniflux
│ ├── privatebin
│ └── vaultwarden
├── hosts
│ ├── dalinar.adyxax.org
│ ├── lumapps-jde.adyxax.org
│ └── myth.adyxax.org
└── lib
└── common
```
### apps
The `apps` directory contains files and configurations about each application I manage. Here is what an app folder looks like:
```
└── apps
└── eventline
├── app.nix
├── borg-db.key
├── borg-db.key.pub
├── borg.nix
├── eventline-entrypoint
└── eventline.yaml
```
Each of the app directories has an `app.nix` file detailing the nix configuration to deploy the app that will be included by the host running it, and a `borg.nix` with the configurations for the host that will be the borg backups target. In my setup each app has its own set of ssh keys (which are encrypted with `git-crypt`) for its borg jobs.
The remaining files are specific to the app. In this example there is a configuration file and a custom entrypoint for a container image.
### hosts
The hosts directory contains the specific configurations and files for each host running nixos. Here is what it looks like:
This way I can `make run host=dalinar.adyxax.org` to build locally dalinar's configuration and deploy it remotely.
## Conclusion
I am quite happy with the simplicity of this system for now. Everything works smoothly and tinkering with the configurations does not involve any magic.
The one thing I really want to improve is the wireguard peers management which is a lot more involved than it needs to be. I will also explore using custom variables in order to simplify the hosts configurations.
In the next articles I will detail the code behind some of these apps and lib files.