This repository contains my Nix and Home Manager configuration for a Darwin (macOS) system, aimed at providing a reproducible development environment with ease of customization.
The repository includes:
- A
flake.nixfile to define system-wide settings, Home Manager integration, and application packages. - A
home.nixconfiguration file to define user-specific settings and packages, making it easy to manage dotfiles and maintain consistency.
The configuration is designed to work with different usernames, allowing easy sharing and reuse across systems without hardcoding user-specific details.
- Nix: Nix must be installed on your system. You can follow the instructions at nixos.org.
- Nix-Darwin: This project uses Nix-Darwin to manage system settings on macOS.
- Home Manager: Home Manager is used to manage user-specific configurations, including dotfiles.
If you don't have Nix installed yet, run the following command to install it:
curl -L https://nixos.org/nix/install | shAfter installation, make sure to enable experimental features for nix-command and flakes by adding the following to /etc/nix/nix.conf or ~/.config/nix/nix.conf:
experimental-features = nix-command flakesInstall Nix-Darwin to manage system settings:
nix build "github:LnL7/nix-darwin"#darwin-installer && ./result/bin/darwin-installerOnce installed, you can use darwin-rebuild to apply system changes.
Home Manager will help manage your user-specific configurations:
nix run github:nix-community/home-manager -- switchClone this repository to your local machine:
git clone https://github.com/maxidelgado/dotfiles.git
cd dotfilesUse the following command to apply the Nix-Darwin and Home Manager configuration:
darwin-rebuild switch --flake ./nix-darwinThis will apply both system and user-specific configurations as defined in flake.nix and home.nix.
The configuration is designed to be reusable for any username. The username is detected dynamically from the environment, which makes the setup flexible for use on different machines.
If you need to modify the settings, edit the following files:
flake.nix: For system-wide configurations, installed packages, and services.home.nix: For user-specific configurations like dotfiles and additional programs.
To add more system-wide packages, edit the environment.systemPackages list in flake.nix. To add user-specific packages, edit the home.packages list in home.nix.
Dotfiles are managed using home.file in home.nix. You can point to any file or directory you want to manage. For example, add more configurations like .vimrc or .gitconfig by editing home.nix.
To update the Nixpkgs version or other inputs, run:
nix flake updateThis will regenerate the flake.lock file to use the latest versions of dependencies.
- Rebuild the System: To apply changes, use:
darwin-rebuild switch --flake . - Home Manager: To manually apply only Home Manager changes, use:
home-manager switch --flake .#your-username
Nix-Darwin is a tool that brings NixOS-like configurations to macOS, allowing you to manage macOS system settings declaratively.
Home Manager allows you to manage user-specific settings, making it easier to keep your dotfiles consistent across machines.
Feel free to open issues or submit pull requests if you find any issues or want to add improvements to this configuration.
This repository is licensed under the MIT License. See the LICENSE file for details.