Top Related Projects
Nix Packages collection & NixOS
A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
Nix User Repository: User contributed nix packages [maintainer=@Mic92]
An Emacs framework for the stubborn martian hacker
Quick Overview
Home Manager is a Nix-based tool for managing user environments. It allows users to declaratively configure their home directory using Nix expressions, enabling reproducible and version-controlled user configurations across different machines.
Pros
- Declarative configuration management for user environments
- Seamless integration with NixOS and other Nix-based systems
- Supports a wide range of applications and services
- Easy rollback and version control of configurations
Cons
- Steep learning curve for users unfamiliar with Nix
- Limited documentation for some modules and advanced use cases
- May require additional setup for non-NixOS systems
- Can be slower than traditional configuration methods due to its declarative nature
Getting Started
To get started with Home Manager, follow these steps:
-
Install Nix if not already installed:
sh <(curl -L https://nixos.org/nix/install) --daemon
-
Add the Home Manager channel:
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update
-
Install Home Manager:
nix-shell '<home-manager>' -A install
-
Edit your Home Manager configuration file:
nano ~/.config/nixpkgs/home.nix
-
Add some basic configuration:
{ config, pkgs, ... }: { home.username = "your-username"; home.homeDirectory = "/home/your-username"; home.packages = with pkgs; [ firefox git vim ]; programs.bash.enable = true; home.stateVersion = "23.05"; }
-
Apply the configuration:
home-manager switch
This will set up a basic Home Manager configuration with some common packages and enable Bash configuration management. You can further customize your environment by adding more modules and options to the home.nix
file.
Competitor Comparisons
Nix Packages collection & NixOS
Pros of nixpkgs
- Larger community and more extensive package collection
- Broader scope, covering system-wide configuration and package management
- More mature project with longer development history
Cons of nixpkgs
- Steeper learning curve for new users
- Can be overwhelming for those only interested in user-specific configurations
- Requires root access for system-wide changes
Code Comparison
nixpkgs:
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
vim
git
firefox
];
}
home-manager:
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
vim
git
firefox
];
}
Key Differences
- home-manager focuses on user-specific configurations, while nixpkgs covers system-wide settings
- home-manager is easier to set up for personal use without affecting the entire system
- nixpkgs offers more flexibility and control over the entire NixOS system
Use Cases
- Use nixpkgs for managing entire NixOS systems and creating custom distributions
- Use home-manager for managing personal dotfiles and user-specific packages across different systems
Integration
home-manager can be used alongside nixpkgs in a NixOS system, allowing for a combination of system-wide and user-specific configurations. This integration provides a powerful and flexible approach to managing both system and user environments.
A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
Pros of nix-direnv
- Lightweight and focused on providing direnv integration for Nix
- Easier to set up and use for simple project-specific environments
- Faster loading times for project environments
Cons of nix-direnv
- Limited scope compared to the comprehensive home management of home-manager
- Requires manual configuration for each project directory
- Less centralized management of user environment
Code Comparison
home-manager:
{ config, pkgs, ... }:
{
home.packages = [ pkgs.htop pkgs.ripgrep ];
programs.git.enable = true;
}
nix-direnv:
use nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [ pkgs.htop pkgs.ripgrep ];
}
Summary
home-manager is a comprehensive tool for managing user environments across an entire system, while nix-direnv focuses on project-specific environments using direnv integration. home-manager offers centralized configuration and broader scope, whereas nix-direnv provides faster, more lightweight setup for individual projects. The choice between them depends on whether you need system-wide management or prefer project-specific environments.
Nix User Repository: User contributed nix packages [maintainer=@Mic92]
Pros of NUR
- Offers a wider variety of packages and configurations from multiple contributors
- Allows users to easily share and discover custom Nix expressions
- More flexible and less opinionated than Home Manager
Cons of NUR
- Less standardized and potentially less stable than Home Manager
- Requires more manual configuration and integration
- May have inconsistent quality across different contributed packages
Code Comparison
Home Manager configuration example:
{ config, pkgs, ... }:
{
home.packages = [ pkgs.htop pkgs.ripgrep ];
programs.git = {
enable = true;
userName = "John Doe";
};
}
NUR usage example:
{ pkgs, ... }:
let
nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
inherit pkgs;
};
in {
environment.systemPackages = [ nur.repos.myuser.mypackage ];
}
Summary
Home Manager provides a more structured and standardized approach to managing user environments, while NUR offers a broader range of community-contributed packages and configurations. Home Manager is generally easier to set up and maintain, but NUR provides more flexibility and variety. The choice between the two depends on the user's specific needs and preferences for managing their Nix-based system.
An Emacs framework for the stubborn martian hacker
Pros of Doomemacs
- Focused on Emacs configuration, providing a curated and optimized setup
- Faster startup times and improved performance compared to vanilla Emacs
- Extensive documentation and active community support
Cons of Doomemacs
- Limited to Emacs configuration, while Home-manager covers a broader range of system configurations
- Less flexibility in terms of system-wide customization
- Steeper learning curve for users not familiar with Emacs
Code Comparison
Home-manager configuration example:
{ config, pkgs, ... }:
{
home.packages = [ pkgs.git pkgs.firefox ];
programs.emacs.enable = true;
}
Doomemacs configuration example:
(doom! :input
:completion
:ui
:editor
:emacs)
While Home-manager uses Nix language for configuration, Doomemacs uses Emacs Lisp. Home-manager allows for system-wide package management and configuration, whereas Doomemacs focuses solely on Emacs setup. Home-manager provides a more comprehensive approach to managing the entire user environment, while Doomemacs offers a specialized, optimized Emacs experience.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Home Manager using Nix
This project provides a basic system for managing a user environment using the Nix package manager together with the Nix libraries found in Nixpkgs. It allows declarative configuration of user specific (non-global) packages and dotfiles.
Usage
Before attempting to use Home Manager please read the warning below.
For a systematic overview of Home Manager and its available options, please see:
If you would like to contribute to Home Manager, then please have a look at "Contributing" in the manual.
Releases
Home Manager is developed against nixpkgs-unstable
branch, which often causes
it to contain tweaks for changes/packages not yet released in stable NixOS.
To avoid breaking users' configurations, Home Manager is released in branches
corresponding to NixOS releases (e.g. release-24.05
). These branches get
fixes, but usually not new modules. If you need a module to be backported, then
feel free to open an issue.
Words of warning
Unfortunately, it is quite possible to get difficult to understand errors when working with Home Manager. You should therefore be comfortable using the Nix language and the various tools in the Nix ecosystem.
If you are not very familiar with Nix but still want to use Home Manager then you are strongly encouraged to start with a small and very simple configuration and gradually make it more elaborate as you learn.
In some cases Home Manager cannot detect whether it will overwrite a previous manual configuration. For example, the Gnome Terminal module will write to your dconf store and cannot tell whether a configuration that it is about to be overwritten was from a previous Home Manager generation or from manual configuration.
Home Manager targets NixOS unstable and NixOS version 24.05 (the current stable version), it may or may not work on other Linux distributions and NixOS versions.
Also, the home-manager
tool does not explicitly support rollbacks at the
moment so if your home directory gets messed up you'll have to fix it yourself.
See the rollbacks section for instructions on how to manually perform a
rollback.
Now when your expectations have been built up and you are eager to try all this out you can go ahead and read the rest of this text.
Contact
You can chat with us on IRC in the channel #home-manager on OFTC. There is also a Matrix room, which is bridged to the IRC channel.
Installation
Home Manager can be used in three primary ways:
-
Using the standalone
home-manager
tool. For platforms other than NixOS and Darwin, this is the only available choice. It is also recommended for people on NixOS or Darwin that want to manage their home directory independently of the system as a whole. See "Standalone installation" in the manual for instructions on how to perform this installation. -
As a module within a NixOS system configuration. This allows the user profiles to be built together with the system when running
nixos-rebuild
. See "NixOS module" in the manual for a description of this setup. -
As a module within a nix-darwin system configuration. This allows the user profiles to be built together with the system when running
darwin-rebuild
. See "nix-darwin module" in the manual for a description of this setup.
Home Manager provides both the channel-based setup and the flake-based one. See Nix Flakes for a description of the flake-based setup.
Translations
Home Manager has basic support for internationalization through gettext. The translations are hosted by Weblate. If you would like to contribute to the translation effort then start by going to the Home Manager Weblate project.
License
This project is licensed under the terms of the MIT license.
Top Related Projects
Nix Packages collection & NixOS
A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
Nix User Repository: User contributed nix packages [maintainer=@Mic92]
An Emacs framework for the stubborn martian hacker
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot