This repository contains a Nix flake to configure a macOS system using the Nix package manager with support for nix-darwin and nix-homebrew.
- Cross-platform configuration: Manage your macOS system with Nix.
- Nix-Darwin integration: System-wide configuration using
nix-darwin
modules. - Homebrew compatibility: Integrate
nix-homebrew
packages in your environment. - Reproducible environment: Define a consistent, versioned configuration for your system.
Ensure that you have the following installed on your macOS system:
- Nix installed with multi-user mode enabled.
- nix-darwin installed.
- nix-homebrew for using Homebrew packages.
-
Install Nix:
sh <(curl -L https://nixos.org/nix/install) --daemon
-
Install nix-darwin: Follow the instructions here.
-
Install nix-homebrew:
nix-shell -p nix-homebrew
Clone this repository locally and navigate to the directory:
git clone https://github.com/your-username/your-nix-flake-repo.git
cd your-nix-flake-repo
You can apply the Nix flake by running the following command:
nix build
Or you can enter a Nix shell environment with the flake configuration:
nix develop
To use the nix-darwin
configuration, rebuild the system using:
darwin-rebuild switch --flake .#
This will apply the system configuration defined in the darwinConfigurations
module of the flake.
You can use Homebrew packages via Nix. For example:
nix-shell -p nix-homebrew gcc
This will open a shell with gcc
installed using Homebrew through Nix.
The flake.nix
defines the following outputs:
packages
: Nix packages for the environment.nix-darwin
: System configurations fornix-darwin
.nix-homebrew
: Support for integrating Homebrew into Nix environments.
{
description = "A simple Nix flake for macOS using nix-darwin and nix-homebrew";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
darwin.url = "github:LnL7/nix-darwin";
homebrew.url = "github:LnL7/nix-homebrew";
};
outputs = { self, nixpkgs, darwin, homebrew }: {
packages = {
darwinConfigurations = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [ ./darwin-configuration.nix ];
};
};
};
}
You can modify flake.nix
or darwin-configuration.nix
to suit your requirements. Add your preferred Homebrew and Nix packages, system settings, and other configurations as needed.
Feel free to open issues or submit pull requests if you encounter any bugs or have suggestions for improvements.
This project is licensed under the MIT License - see the LICENSE file for details.