This repository provides a template for declarative configuration of NixOS and macOS systems using Nix flakes. It's designed to manage system, user, and application configurations in a structured and reproducible way.
.
├── dots/ # Dotfiles and application configurations
│ ├── auto/ # Configurations to be automatically linked into XDG_CONFIG_HOME
│ └── modules/ # Dotfile setups that relate to toggleable nix modules (manually linked by module)
├── flakes/ # Custom Nix flakes for things like editors or project templates
│ ├── apps/ # Fully contained applications wrapped as a nix flake for use cross-platform
│ └── overlays/ # Custom nix packages, bundled as a flake, usable as overlays to other flakes
│ └── templates/ # Flake templates, for quick devenv inits
├── hosts/ # Host-specific configurations (one directory per machine)
├── modules/ # Reusable Nix modules for configuring systems and home environments
│ ├── darwin/ # macOS-specific modules
│ ├── nixos/ # NixOS-specific modules
│ └── shared/ # Cross-platform modules for both NixOS and macOS
├── profiles/ # User-specific configurations (e.g., 'work' or 'personal' profiles)
└── projects/ # Mini projects related to my system configuration
hosts/: Contains the complete, host-specific system configurations for your different machines.modules/: Holds reusable configuration modules, organized by platform (darwin/nixos/shared), to keep your setup DRY.dots/: Manages your application dotfiles and configurations declaratively.flakes/: A place for custom Nix flakes, such as a fully configured editor setup or project templates.packages/: For any custom package definitions that aren't available in the official nixpkgs repository.profiles/: Allows you to define different user profiles with specific sets of tools and configurations.projects/: Contains Nix flakes for setting up development environments for your various projects.
This setup automatically links dotfiles from the dots/auto/ directory to your XDG config directory (~/.config) using GNU Stow. This is handled by a pre-configured Home Manager module.
To have a configuration for a new application automatically linked:
-
Create a directory for your application in
dots/auto/. -
Add your configuration files to that new directory.
Example: To add a configuration for
my-app, you would createdots/auto/my-app/config.toml. This will be automatically linked to~/.config/my-app/config.toml. -
Rebuild your system. The modules included in this repository will handle the rest.
-
Install Nix:
sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) -
Close and restart your shell.
-
Clone this repository:
git clone <your-repository-url> MyNixConfig cd MyNixConfig
If submodules are present in repo, pull them
git submodule update --init --recursive
-
Install the system flake using
nix-darwin:nix build .#darwinConfigurations.<hostname>.system --extra-experimental-features 'nix-command flakes' --impure sudo ./result/sw/bin/darwin-rebuild switch --flake .#<hostname> --impure
(Replace
<hostname>with the name of your host configuration from thehostsdirectory).
- During the NixOS installation, clone this repository into
/mnt/etc/nixos. - Run the installation command:
(Replace
nixos-install --flake /mnt/etc/nixos#<hostname>
<hostname>with the name of your host configuration).