The dots used to be managed by a custom script that I wrote, which was very much prone to breakages, so I took a flaky approach.
This is an experimental branch where I’m testing nix.
I wish to work with a single file mindset and see how far I can take it, that’s why I opted to not use home-manager and use GNU Stow instead for dotfiles symlink.
- Flakes first steps
- Shell scripts with nix
- Installing a specific version with nix (explains how to work with overlays)
- Declarative management of dotfiles with Nix and Home Manager
- Managing dotfiles with nix
- Get the list of packages to replace using
brew leaves
. - Install nix:
curl -L https://nixos.org/nix/install | sh
.
- Create ./flake.nix
- (Check *Macos exclusive stuff if you’re running darwin)
Run
nix --extra-experimental-features "nix-command flakes" profile install . --impure
in the dotfiles directory. - Run
stow <dir>
to symlink the dotfiles. e.g.:stow nix
(To not link and see what the stow command will do, runstow -nv linux
) - To upgrade the packages, run
nix flake update
and thennix profile upgrade dotfiles --impure
- To upgrade specific flake inputs
nix flake update emacs-overlay
- Remember to run
nix-collect-garbage -d
to clean up old generations and to save space.
- Most of the apps are installed using
nix-homebrew
and system configuration happens vianix-darwin
- I have created two aliases for working with darwin, they are
nix-update-mac
anddarwin-rebuild-mac
respectively. These have to set theHOSTNAME
envVar which is used in the flake file fordarwinConfigurations
.
alias nix-update-mac='HOSTNAME=$(hostname -s) nix build .#darwinConfigurations.$(hostname -s).system --impure'
alias darwin-rebuild-mac='HOSTNAME=$(hostname -s) ./result/sw/bin/darwin-rebuild switch --flake . --impure'