NixOS + home-manager configs, mirrored from GitLab SaaS.
gitlab.com/andreijiroh-dev/nixops-config
nix-flake
nixos
home-manager
nixpkgs
nix-flakes
This repository contains NixOS and Home Manager configurations for various machines. The goal is to manage system and user configurations declaratively using Nix.
Project Structure#
The repository is structured as a Nix flake.
flake.nix: The main entry point. It defines the flake's inputs (likenixpkgs,home-manager, etc.) and outputs. The main outputs arenixosConfigurationsfor NixOS hosts andhomeConfigurationsfor home-manager configurations on both NixOS and non-NixOS hosts.hosts/: Contains the configurations for specific machines. Each subdirectory corresponds to a host and contains aconfiguration.nixfile, which is the main configuration for that host.shared/: Contains modules that are shared across different hosts. This is where most of the configuration logic resides.shared/desktop/: Desktop specifics (Bluetooth, Plasma, Firefox, Yubikey, etc.).shared/server/: Server-side configurations (SSH, Firewall, Tailscale, Cockpit).shared/home-manager/: Home Manager configurations for user-specific dotfiles and packages.shared/shells/: Shell configurations (Bash, custom prompts).shared/vscode/: VSCode related settings.
pkgs/: Custom packages defined in this flake (e.g.,coolify-compose,detect-vscode-for-git).scripts/: Helper scripts for deployment and maintenance.misc/: Miscellaneous configurations and library scripts (e.g.,starship.toml, bash helper functions).
Key Concepts#
- NixOS Modules: The configurations are built using the NixOS module system. The
shared/directory contains many reusable modules. When you need to add or change a configuration, you'll likely be editing one of these files or creating a new one. - Home Manager: Home Manager is used to manage user-level configurations (dotfiles, packages, services). The main Home Manager configuration is in
shared/home-manager/main.nix. - Flake Outputs:
nixosConfigurations: System configurations for hosts.homeConfigurations: Standalone Home Manager configurations.packages: Custom packages exported by this flake.overlays: Nixpkgs overlays to make custom packages available to system configurations.exportedConfigs: Reusable modules exported for external consumers.
Developer Workflow#
Adding a new host#
- Create a new directory in
hosts/for the new host. - Add a
configuration.nixfile inside the new directory. You can use one of the existing host configurations as a template. - Add a new entry to the
nixosConfigurationsinflake.nixfor the new host, pointing to your newconfiguration.nix. - Import the necessary shared modules into your
configuration.nix.
Modifying a configuration#
- Identify which module or host configuration you need to change.
- Make your changes to the respective
.nixfile. - To apply the changes to a machine, run
sudo nixos-rebuild switch --flake .#<hostname>on that machine, where<hostname>is the name of the host you want to update.
Updating dependencies#
To update the flake's inputs (e.g., nixpkgs), run:
nix flake update
This will update the flake.lock file with the latest versions of the dependencies.
Important Files#
flake.nix: The central point of the configuration.shared/meta.nix: Imports a base set of shared modules.shared/home-manager/main.nix: The main entry point for user-specific configurations managed by Home Manager.shared/home-manager/nogui.nix: A headless Home Manager configuration (used inplainconfigs).hosts/<hostname>/configuration.nix: The main configuration file for a specific host.hosts/<hostname>/users/<username>.nix: User-specific configurations for a given host, leveraging Home Manager. Seehosts/stellapent-cier/users/gildedguy.nixfor an example.hosts/live-cd/base.nixandhosts/live-cd/kde-plasma.nix: Live CD-specific NixOS configurations.idx/: Firebase Studio specific dev environment configurations. See @.idx/AGENT.md for details.
When working on this codebase, remember that it's all about declarative configuration. Instead of changing things imperatively on the system, you declare the desired state in these .nix files, and Nix takes care of making it happen.