Skip to content

Complete Nix workflow for macOS. Let the snowflakes in. ❄️

Notifications You must be signed in to change notification settings

lanjoni/snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snowflake

It's like magic. Let the snowflakes in. ❄️

Nothing more than a configuration using flakes, nix-darwin and home-manager.

These are my complete configurations for use in my daily life using macOS alongside Nix, which is more than my main package manager, being the most powerful tool alongside home-manager and nix-darwin.

Maybe this is the time to try something new. If you want, start by running sh <(curl -L https://nixos.org/nix/install) --daemon in your terminal.

Installation

Once you have Nix properly installed on your machine, now is the time to clone this configuration to ~/.config/snowflake and start having fun in the snow.

git clone https://github.com/lanjoni/snowflake.git ~/.config/snowflake

After cloning the repository we can build with nix-darwin:

# This will activate flakes to start the installation and build. Note that my machine name is "artemis".
nix --extra-experimental-features "nix-command flakes" build .#darwinConfigurations.artemis.system

Then just run:

# nix-darwin will perform a complete rebuild of the system.
./result/sw/bin/darwin-rebuild switch --flake ~/.config/snowflake/.#artemis

Done. Now, my entire workflow is in your hands for use. With flakes I can guarantee that everything is in its specific version, validating inconsistencies and guaranteeing a perfect replica.

Configuration

Now let's talk a little about the organizational structure here so we can analyze more carefully how everything works.

Structure

Take a look:

.
├── README.md
├── flake.lock
├── flake.nix
├── img
│   ├── darwin.png
│   └── nix.png
├── modules
│   ├── darwin
│   │   ├── default.nix
│   │   └── settings
│   │       ├── environment.nix
│   │       ├── homebrew.nix
│   │       ├── system.nix
│   │       └── services.nix***
│   └── home-manager
│       ├── default.nix
│       └── settings
│           ├── inputrc
│           ├── apps.nix***
│           └── zsh.nix
└── result -> /nix/store/somehash

The apps.nix*** and services.nix*** files are symbolic only and indicate specific application and service configurations only. While applications are managed by home-manager, services are managed directly by nix-darwin as they need permissions to bootstrap and control with launchctl.

Files

  • flake.nix: Contains the base configuration of our flake, controlling the expected inputs and outputs, in addition to managing the external urls of home-manager and nix-darwin;
  • modules/darwin/default.nix: Contains the complete configuration of our nix-darwin, including imports for configurations, extra options, among others;
  • modules/darwin/settings/environment.nix: Contains the complete environment configuration, including system path, system packages and login shell (zsh in this case);
  • modules/darwin/settings/homebrew.nix: Contains the homebrew configuration, including casks, brews and taps;
  • modules/darwin/settings/system.nix: Contains the entire system configuration, including appearance, dock management, I/O devices settings, and others;
  • modules/home-manager/default.nix: Contains the home-manager configuration imports, packages and session variables;
  • modules/home-manager/settings/inputrc: This is just que inputrrc file for input settings with home-manager;
  • modules/home-manager/settings/zsh.nix: Contains the entire zsh configuration (similar to your .zshrc with steroids);
  • result: A symlink which apoints to your build at /nix/store.

Note: if you want to install a simple package, go to modules/home-manager/default.nix and add the package name to the home.packages list. But, if you want to strictly configure your package, then include a file in modules/home-manager/settings with the name of your package and its settings following the template below:

# At modules/home-manager/settings/yourpackage.nix
{ pkgs, ... }: {
  programs.yourpackage = {
    # Your settings
  };
}

And don't forget to import in modules/home-manager/default.nix:

# ...
  imports = [
    ./settings/zsh.nix
    ./settings/yourpackage.nix
  ];
# ...

Amazing! To search for packages you can use the official search at nixos.org.

Documentation

To find more content about Nix, follow the links below:

Talks and presentations about Nix and NixOS:

Issues

Any problems with the workflow, documentation or code? Submit an issue.

About

Complete Nix workflow for macOS. Let the snowflakes in. ❄️

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages