Complete guide for Nix operations including home-manager apply, nix-darwin apply, package installation, rollback procedures, architecture support (Apple Silicon/Intel Mac), and NixOS configuration
Basic operations are performed using make.
This repository supports Apple Silicon, Intel Mac, and NixOS. The architecture is auto-detected at build time.
| Architecture | nixpkgs | nix-darwin | home-manager |
|---|---|---|---|
| Apple Silicon (aarch64-darwin) | unstable | unstable | unstable |
| Intel Mac (x86_64-darwin) | unstable | unstable | unstable |
| NixOS (x86_64-linux) | unstable | N/A | unstable |
# Apply all NixOS settings (includes home-manager)
sudo nixos-rebuild switch --flake .#desktop
# Build only (no activation)
sudo nixos-rebuild build --flake .#desktop
# Test configuration temporarily
sudo nixos-rebuild test --flake .#desktop
# Apply home-manager configuration (update flake + switch)
make home-manager-apply
# Apply home-manager configuration (no flake update)
make home-manager-switch
# Build only (no activation)
make home-manager-build
make nix-darwin-apply
make nix-darwin-homebrew-apply
make nix-darwin-system-apply
make nix-darwin-service-apply
# Update flake inputs and apply all darwin settings
make nix-update-all
# CI environment: Test without actual activation (macOS)
make nix-check-all
# Update Nix channel to latest unstable
make nix-channel-update
# Update all flake.lock files (darwin, nixos, nixvim)
make flake-update-all
# Update darwin/flake.lock only
make flake-update-darwin
# Update nixos/flake.lock only
make flake-update-nixos
# Update nixvim/flake.lock only
make flake-update-nixvim
# Run Nix garbage collection
make nix-gc
# Completely uninstall Nix
make nix-uninstall
# search package: https://search.nixos.org/packages
# install package
nix profile install nixpkgs#hoge
nix profile upgrade hoge
nix-env --list-generations
1 2024-10-17 10:19:29
2 2024-10-17 11:55:16
3 2024-10-17 19:19:37
4 2024-11-06 18:37:37
5 2024-11-06 18:52:58 (current)
nix-env --rollback
# or
nix-env --switch-generation 3
While most dotfiles configurations are managed through the Nix store for reproducibility and immutability, the Claude configuration is handled as an exception using direct symbolic links.
Rationale:
Implementation: The Claude configuration files are linked directly from the dotfiles repository:
macOS (darwin):
~/.claude/CLAUDE.md → ~/git_repos/github.com/barleytea/dotfiles/darwin/home-manager/claude/config/CLAUDE.md
~/.claude/settings.json → ~/git_repos/github.com/barleytea/dotfiles/darwin/home-manager/claude/config/settings.json
NixOS:
~/.claude/CLAUDE.md → ~/git_repos/github.com/barleytea/dotfiles/nixos/home-manager/claude/config/CLAUDE.md
~/.claude/settings.json → ~/git_repos/github.com/barleytea/dotfiles/nixos/home-manager/claude/config/settings.json
This approach enables:
Configuration Location:
darwin/home-manager/claude/default.nixnixos/home-manager/claude/default.nix~/.claude/If you install pre-built binaries that target "generic" Linux environments (for example the Claude CLI), NixOS will refuse to start them with an error like:
Could not start dynamically linked executable: claude
NixOS cannot run dynamically linked executables intended for generic linux environments out of the box.
The nixos/system/default.nix module now enables programs.nix-ld with the common runtime libraries (glibc, libstdc++, openssl, zlib, libX11, etc.) so these binaries can locate their dependencies. After updating the flake, rebuild the machine to pick up the loader:
sudo nixos-rebuild switch --flake .#desktop
If a third-party binary still complains about missing libraries, extend the programs.nix-ld.libraries list in nixos/system/default.nix with the required packages and rebuild again.