macOS/Linux - Nix ConfigΒΆ
For full documentation, visit hugohakem.github.io/nix-os.config.
My Nix config is heavily inspired by:
dustinlyons for base NixOS + macOS configuration
afermg: Moby Config for home-manager (and my introduction to the Nix ecosystem)
leoank: Neusis Config for templates
MotivationΒΆ
I chose Nix as my package manager because it enables:
Declarative Configuration: You can specify your configuration like a recipe, and Nix will seamlessly recreate it on any intended system. Sharing configs and environments becomes effortless!
Reproducibility: If it works on my machines, it will work on yours! With its inherent
.lock
file, package versioning is guaranteed to be consistent.Reliability: Even if your build fails, previously installed packages remain intact, and you can easily roll back to previous build versions.
Note that NixOS is an operating system built on these concepts. Itβs even more configurable, with hardware specifications, etc. I havenβt chosen this option yet as it is more advanced and less beginner-friendly. However, itβs possible to install NixOS on GCP (see Resources), and I may explore that in the future if a use case arises.
This Nix config relies on Nix Home Manager. I highly recommend checking the home-manager tutorial below in the resources section if you want to get familiar with the Nix syntax and how to obtain a minimal configuration.
Project LayoutΒΆ
.
βββ apps # Custom nix commands written in shell script
βΒ Β βββ ...
βΒ Β βββ README.md
βββ flake.lock
βββ flake.nix # Core config
βββ gcp-installation.md
βββ hosts # Where `modules` are imported
βΒ Β βββ darwin
βΒ Β β βββ ...
βΒ Β βββ linux
βΒ Β β βββ ...
βΒ Β βββ README.md
βββ modules # Where files, packages, and programs are defined
βΒ Β βββ darwin
βΒ Β βΒ Β βββ ...
βΒ Β βΒ Β βββ README.md
βΒ Β βββ linux
βΒ Β βΒ Β βββ ...
βΒ Β βΒ Β βββ README.md
βΒ Β βββ shared
βΒ Β βββ config # Program configs like vscode, zsh, emacs
βΒ Β βΒ Β βββ ...
βΒ Β Β Β βββ ...
βΒ Β βββ README.md
βββ overlays # Package fixes
βΒ Β βββ ...
βΒ Β βββ README.md
βββ templates # Project templates
βββ deprecated # Archived / for learning purposes
βΒ Β βββ ...
βββ pythonml
βΒ Β βββ ...
βββ README.md
Getting StartedΒΆ
To set up a new machine, please follow the corresponding guide:
For Linux:
gcp-installation.md
Note: Originally intended for setting up a Google Cloud Virtual Machine.
Note: Supports installation of CUDA drivers. See nvidia-drivers-installation.md for details.
For macOS:
mac-installation.md
These guides will refer you to the various README.md
files outlined in the Project Layout. You will find useful explanations to help you understand the code and get familiar with Nix as a package manager. Useful commands and typical workflows are also documented there.
To set up a new project with templates/pythonml
, add it to your project directory by running the following commands in your $HOME
directory:
mkdir projects
cp -r nixos-config/templates/pythonml projects/[name-of-the-project]
For further details, refer to templates/
.
Note on My EditorΒΆ
As of today, my editor of choice is Visual Studio Code. However, you may find some Emacs
-related code in modules/shared/config/emacs/. As I have paused my Emacs journey for now, any Emacs code has been commented out. See the note on my editor in modules/shared/config/README.md to learn how to change the Visual Studio Code configuration to suit your needs.
To-DoΒΆ
[ ] Test config on a blank GCP virtual machine
[ ] Eventually add guidelines on how to minimally set up a virtual machine
[ ] Test config on a new Mac and add installation guide
[ ] Complete [mac-installation.md]
[ ] Learn Emacs or Vim and provide my custom config as a safeguard for systems where VSCode remote-ssh is not possible
[ ] Provide custom configs for WezTerm and Zsh
Resources to Keep in MindΒΆ
Nix Official ResourcesΒΆ
SearchΒΆ
Nix options β useful for searching
services
ManualsΒΆ
NixOS installation guide for Google Cloud Engine β moves completely away from Linux and installs NixOS. Less beginner-friendly but worth exploring for full reproducibility and control.
GitHub ReposΒΆ
TutorialsΒΆ
AcknowledgementsΒΆ
As mentioned above, this configuration relies heavily on the NixOS/macOS backbone provided by dustinlyons, as well as afermg: Moby Config and leoank: Neusis Config.
I am particularly grateful to AlΓ‘n for introducing me to Nix and for his mentorship throughout my learning. I also thank Ank for the insightful discussions that helped refine my understanding of Nix.
As I am still learning about Nix, if you notice anything missing, bugs, or features that should be added, feel free to open an issue.