How It Works
Comin is a NixOS service that:- Monitors a Git repository for changes
- Pulls updates from specified branches
- Rebuilds the NixOS configuration
- Applies changes automatically
Configuration
The GitOps functionality is provided by thecore.gitops module:
Enabling GitOps on a System
Verify comin is running
Check the service status:You should see the service is active and monitoring the repository.
Comin Service Configuration
The module translates options into comin’s service configuration:Key Parameters
- hostname: Matches the flake output name (e.g.,
nixosConfigurations.zephyrus) - remotes: Git repositories to monitor
- branches.main.name: Which branch to track (typically
mainormaster)
GitOps Workflow
Development Workflow
- Make changes in a development environment
- Test locally with
nixos-rebuild test - Commit and push to a feature branch
- Test on a non-production system
- Merge to
mainbranch - Production systems automatically deploy
Rollback Procedure
If a deployment causes issues:Branch Strategy
Single Branch (Simple)
- All systems track
main - Changes deploy to all systems simultaneously
- Best for homelab environments
Multi-Branch (Advanced)
- Development systems track
develop - Production systems track
main - Allows staged rollouts
Monitoring Deployments
Check comin logs
View deployment history
Security Considerations
Authentication for Private Repositories
Using Deploy Keys
-
Generate an SSH key on the system:
- Add the public key as a deploy key in GitHub/GitLab
-
Configure comin to use the key:
Using GitHub Tokens
For HTTPS repositories, embed a token in the URL:Disabling GitOps Temporarily
To stop automatic deployments without removing the configuration:Troubleshooting
Comin not pulling changes
Check the repository URL and branch configuration:Build failures
Comin will retry automatically. Check the logs:Authentication failures
Verify SSH keys or tokens are correctly configured:Best Practices
- Use atomic commits (one logical change per commit)
- Write descriptive commit messages
- Test changes locally before pushing
- Monitor the first deployment after enabling GitOps
- Keep secrets in agenix, not in the Git history
- Use pull requests for critical infrastructure changes