This is my personal Nix configuration used on MacOS.
- install nix version 2.4 or later
- install nix-darwin
note:
you don’t need to install home-manger, nix-darwin will install it instead.
- Clone this to
$HOME/src/nix
cd $HOME/src && git clone https://github.com/Eason0210/nix.git
- Change all the username(aqua0210 is my username) in
darwin.nix
andhome.nix
- Remove apps you don’t need in
packages.nix
- Check all the config is good for you and run this command in terminal.
nix build ~/src/nix\#darwinConfigurations.MacBook.system
# when build succeed, run:
darwin-rebuild switch --flake ~/src/nix
hint:
MacBook is my hostname
darwin-rebuild --list-generations # list all generations
darwin-rebuild --rollback # rollback to previous generation
nix-collect-garbage -d # remove all other generations except current one
Please refer to nix-community/emacs-verlay
- EmacsGit install the master branch of Emacs, recently is Emacs 28.0.50
- Emacs install Emacs latest realease, Emacs 27.2
- EmacsGcc Install master branch with options
--with-native-compilation
enabled
You need to specify a specific Git revision, along with its hash, in order to avoid re-downloading new versions of the overlay constantly.
Concretely, that means:
- Change the master string in the url field of builtins.fetchTarball to a specific commit hash.
- Add a sha256 field to builtins.fetchTarball set to 0000000000000000000000000000000000000000000000000000
- Try to build (
darwin-rebuild switch
) - It will complain about the hash being incorrect (expected zeros, actually the real hash)
- Replace the zeros with the real hash
… Profit
refer to this issue.
- Nix Multi User Installation (Nix 2.4 or later)
- Refer to nix-on-macos-catalina.md (before Nix 2.4)