Skip to content

buntec/nix-config

Repository files navigation

My personal Nix configuration flake

Configures my personal machines (NixOS and macOS).

If you spot any errors or mistakes, feel free to open a pull request!

Fresh NixOS install

After installing NixOS from a USB drive, follow these steps:

  1. Clone this repo and cd into it.

  2. Copy /etc/nixos/hardware-configuration.nix into ./system (OK to overwrite existing dummy file).

  3. Build and activate NixOS config:

sudo nixos-rebuild switch --flake .#thinkpad-x1 # the fragment can be dropped if it matches your current host name

# alternatively, using the `apps` provided by the flake:
sudo nix run .#rebuild-thinkpad-x1
  1. Activate home-manager:
sudo nix run .#hm-switch-thinkpad-x1

Notes:

On a Thinkpad X1 you might have to remove the line

hardware.video.hidpi.enable = lib.mkDefault true;

from hardware-configuration.nix if nixos-rebuild complains about this option having no effect.

Fresh macOS install

(Inspired by this gist.)

To bootstrap a fresh macOS install, follow these steps:

  1. Install Homebrew (only needed for managing GUI apps via casks)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Nix:
curl -L https://nixos.org/nix/install | sh
  1. Enable flakes
mkdir -p ~/.config/nix
cat <<EOF > ~/.config/nix/nix.conf
experimental-features = nix-command flakes
EOF
  1. (Probably no longer needed.) To work around this issue
sudo mv /etc/nix/nix.conf /etc/nix/.nix-darwin.bkp.nix.conf
  1. Clone this repo, cd into it, then build and activate:
nix run .#rebuild-macbook-pro-m1 # nix-darwin
nix run .#hm-switch-macbook-pro-m1 # home-manager

Migrating an existing macOS install to Nix

  1. Uninstall Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
  1. Delete everything under ~/.config and any other "dot files" in your home directory.

  2. Delete all applications that are listed as Homebrew casks in ./system/configuration-darwin.nix

  3. Follow the steps for a fresh macOS install.

About

My personal Nix config files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published