| name | nix-operations |
| description | 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 |
Nix operations
Basic operations are performed using make.
Architecture Support
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 |
Nix
NixOS: Apply system and home-manager settings
sudo nixos-rebuild switch --flake .#desktop
sudo nixos-rebuild build --flake .#desktop
sudo nixos-rebuild test --flake .#desktop
macOS: Apply home-manager settings (standalone)
make home-manager-apply
make home-manager-switch
make home-manager-build
macOS: Apply all nix-darwin settings
make nix-darwin-apply
Apply nix-darwin-homebrew settings
make nix-darwin-homebrew-apply
Apply nix-darwin-system settings
make nix-darwin-system-apply
Apply nix-darwin-service settings
make nix-darwin-service-apply
macOS: Apply all nix settings
make nix-update-all
make nix-check-all
Update Nix channels
make nix-channel-update
Update flake inputs
make flake-update-all
make flake-update-darwin
make flake-update-nixos
make flake-update-nixvim
Maintenance
make nix-gc
make nix-uninstall
Install a new package
nix profile install nixpkgs#hoge
Upgrade a package
nix profile upgrade hoge
Rollback
1. Check generations
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)
2. Rollback
nix-env --rollback
nix-env --switch-generation 3
Special Configuration Handling
Claude Configuration
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:
- Claude Desktop application modifies its configuration files directly during runtime
- The Nix store approach would prevent Claude from updating its own settings
- Direct symbolic links allow bidirectional synchronization between the application and dotfiles
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:
- Claude to modify its configuration files as needed
- Changes to persist in the dotfiles repository automatically
- Version control of Claude settings through git
Configuration Location:
- Dotfiles (darwin):
darwin/home-manager/claude/default.nix
- Dotfiles (NixOS):
nixos/home-manager/claude/default.nix
- Target directory:
~/.claude/
NixOS: Running Generic Linux Binaries
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.