Harnessing Nix,Flakes,Nix-Darwin, and Home Manager to manage macOS system settings and dotfile configurations
├── Makefile
├── README.md
├── configs
├── flake.lock
├── flake.nix
└── modules
├── darwin
│ ├── custom
│ ├── default.nix
│ ├── services
│ └── settings
│ ├── default.nix
│ ├── environment.nix
│ ├── nix-settings.nix
│ └── system.nix
└── home-manager
├── cliPkgs.nix
├── default.nix
├── manual.nix
└── programs
Makefile
: Contains commands to simplify common tasks, such as updating and building configurations.flake.lock
: Lock file for the Nix flake, ensuring reproducibility.flake.nix
: Main entry point for the Nix flake, defining inputs, outputs, and configuration.default.nix
: Main entry point for system configuration.modules/customServices
: Custom services configuration.
borders.nix
: Configuration for window borders.default.nix
: Default custom services configuration.services
: Configuration for system services.
borders.nix
: Service configuration for borders.default.nix
: Default services configuration.sketchybar.nix
: Configuration for SketchyBar.skhd.nix
: Configuration for Skhd (hotkey daemon).yabai.nix
: Configuration for Yabai (window manager).settings
: System settings configuration.
default.nix
: Default system settings.environment.nix
: Environment variables.nix-settings.nix
: Nix-specific settings.system.nix
: System-wide settings.cliPkgs.nix
: CLI packages configuration.default.nix
: Main entry point for Home Manager configuration.manual.nix
: Post-activation and manual scripting, such as file moving and symlink creation.programs
: Specific program configurations.
fzf.nix
: Configuration for FZF (fuzzy finder).misc.nix
: Miscellaneous program settings.starship.nix
: Configuration for the Starship prompt.sketchybar
: Contains the configuration files and plugins for SketchyBar.
plugins
: Contains various shell scripts used by SketchyBar.sketchybarrc
: Main configuration file for SketchyBar.Ensure you have Nix and Nix-Darwin installed on your macOS system.
Clone the Repository:
git clone <repository-url>
cd <repository>
Build and Apply Configuration:
make build
make switch
The Makefile
contains targets to simplify the process:
make build
: Builds the configuration.make switch
: Switches to the new configuration.make darwin-refresh
: Refreshes the Nix-Darwin configuration.To update the configuration or dependencies, use the following commands:
nix flake update
make build
make switch
The manual.nix
file contains scripts and configurations for handling post-activation tasks and manual operations, such as file moving and symlink creation for services like SketchyBar.
Home Manager Activation:
{ lib, pkgs, ... }:
{
home.activation.sketchybar = lib.hm.dag.entryAfter ["writeBoundary"] ("${pkgs.sketchybar}/bin/sketchybar --reload");
home.file = {
".config/sketchybar".source = ../../configs/sketchybar;
};
}
Post-Activation Script in Darwin Configuration:
system.activationScripts.postUserActivation.text = ''
# Following line should allow us to avoid a logout/login cycle
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
# To reflect Dock Changes (Risky)
killall Dock
'';
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
: Applies system settings immediately, avoiding the need for a logout/login cycle.killall Dock
: Restarts the Dock to apply any changes made to its configuration.Comment the above activation script if you are not aware
#
at the beginning of each line.Feel free to customize the configuration files to suit your needs. The modular structure allows for easy addition and modification of settings and services.
Contributions are welcome! Feel free to open issues or pull requests to improve this configuration.
This README provides an overview and guide for using and customizing your Nix-Darwin and Home Manager setup. Feel free to adjust the details according to your specific setup and preferences.