Skip to content

Instantly share code, notes, and snippets.

@bernadinm
Created November 1, 2022 08:07
Show Gist options
  • Save bernadinm/a8b8a994c633dc250ecb515be66faa77 to your computer and use it in GitHub Desktop.
Save bernadinm/a8b8a994c633dc250ecb515be66faa77 to your computer and use it in GitHub Desktop.
Home-manger MacOS Nix Installation Instruction

Nix MacOS Home Manager Installation Guide

Prequisite

Install Nix with the following command

sh <(curl -L https://nixos.org/nix/install)

Install Home-Manager

Download home-manager channel

nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
nix-channel --update

Fetch home-manager binary

nix-shell '<home-manager>' -A install

Test home-manager to ensure this is installed.

home-manager

Save Files in Git

Create your file in your gitrepo

cat > /Users/miguel.bernadin/git/bernadinm/nix-config/hosts/mbp/work/configuration.nix <<EOF
{ config, pkgs, ... }:

{
  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "miguel.bernadin";
  home.homeDirectory = "/home/miguel.bernadin";

  # This value determines the Home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new Home Manager release introduces backwards
  # incompatible changes.
  #
  # You can update Home Manager without changing this value. See
  # the Home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "21.05";
}
EOF

Update zshrc file

export NIX_PATH=/nix/var/nix/profiles/per-user/$(whoami)/channels:$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi

Execute Home-Manager

home-manager switch -f ~/git/bernadinm/nix-config/hosts/mbp/work/configuration.nix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment