garden.packages attribute instead of the traditional environment.systemPackages or home.packages. This approach prevents duplicate package listings and simplifies package management across both NixOS and home-manager configurations.
The garden.packages pattern
Instead of separate lists for system and user packages, you define packages once in an attribute set:Why use an attribute set instead of a list?
Why use an attribute set instead of a list?
Using an attribute set for packages provides several benefits:
- No duplicates - Each package name can only appear once
- Better composition - Easy to merge package sets from different modules
- Named packages - Clear what each package is for
- Custom packages - Define wrapped or modified packages inline
Adding packages to your user
Create or edit your user's packages.nix
Create or edit
/home/<user>/packages.nix:home/yourname/packages.nix
Conditional packages
You can conditionally include packages based on profiles or platform:Custom and wrapped packages
You can define custom packages or wrap existing ones:Real-world examples
Workstation packages
Fromhome/isabel/packages.nix:
home/isabel/packages.nix
Development environment
home/yourname/packages.nix
System-level packages
For system-wide packages (available to all users), use the same pattern in your system configuration:systems/yoursystem/default.nix
Package organization tips
Finding packages
Search for packages in nixpkgs:- Web search
- Command line
- Nix REPL
Visit search.nixos.org to browse available packages.
Next steps
Adding users
Create users to install packages for
Adding systems
Configure systems with packages
Troubleshooting
Fix package installation issues
Templates
Use Nix flake templates