diff --git a/index.xhtml b/index.xhtml index 0480b51ce..6fd67230f 100644 --- a/index.xhtml +++ b/index.xhtml @@ -33,7 +33,7 @@
-

Table of Contents

Preface
Introduction to Home Manager
Installing Home Manager
Standalone installation
NixOS module
nix-darwin module
Using Home Manager
Configuration Example
Rollbacks
Keeping your ~ safe from harm
Graphical services
GPU on non-NixOS systems
Updating
Nix Flakes
Prerequisites
Standalone setup
NixOS module
nix-darwin module
flake-parts module
Writing Home Manager Modules
Option Types
Contributing
Getting started
Guidelines
News
Tests
Third-Party Tools and Extensions
Module Collections
Frequently Asked Questions (FAQ)
Why is there a collision error when switching generation?
Why are the session variables not set?
How to set up a configuration for multiple users/machines?
Why do I get an error message about ca.desrt.dconf or dconf.service?
How do I install packages from Nixpkgs unstable?
How do I change the package used by a module?
A. Home Manager Configuration Options
B. NixOS Configuration Options
C. nix-darwin Configuration Options
D. Release Notes
+

Table of Contents

Preface
Introduction to Home Manager
Installing Home Manager
Standalone installation
NixOS module
nix-darwin module
Using Home Manager
Configuration Example
Rollbacks
Keeping your ~ safe from harm
Graphical services
GPU on non-NixOS systems
Updating
Nix Flakes
Prerequisites
Standalone setup
NixOS module
nix-darwin module
flake-parts module
Writing Home Manager Modules
Option Types
Contributing
Getting started
Guidelines
News
Tests
Home Manager Internals
Activation
Third-Party Tools and Extensions
Module Collections
Frequently Asked Questions (FAQ)
Why is there a collision error when switching generation?
Why are the session variables not set?
How to set up a configuration for multiple users/machines?
Why do I get an error message about ca.desrt.dconf or dconf.service?
How do I install packages from Nixpkgs unstable?
How do I change the package used by a module?
A. Home Manager Configuration Options
B. NixOS Configuration Options
C. nix-darwin Configuration Options
D. Release Notes

List of Examples

1. Home Manager Rollback

Preface

This manual will eventually describe how to install, use, and extend Home Manager.

If you encounter problems then please reach out on the IRC channel #home-manager @@ -338,21 +338,35 @@ programs and service options – Emacs is

or if you are not feeling so lucky,

home-manager build
 

which will create a result link to a directory containing an activation script and the generated home directory files.

-

Rollbacks

While the home-manager tool does not explicitly support rollbacks at -the moment it is relatively easy to perform one manually. The steps to -do so are

  1. Run home-manager generations to determine which generation you -wish to rollback to:

    $ home-manager generations
    -2018-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation
    -2018-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation
    -2018-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
    -2017-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation
    -2017-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation
    +

Rollbacks

When you perform a home-manager switch and discover a problem then +it is possible to roll back to the previous version of your +configuration using home-manager switch --rollback. This will turn +the previous configuration into the current configuration.

Example 1. Home Manager Rollback

Imagine you have just updated Nixpkgs and switched to a new Home +Manager configuration. You discover that a package update included in +your new configuration has a bug that was not present in the previous +configuration.

You can then run home-manager switch --rollback to recover your +previous configuration, which includes the working version of the +package.

To see what happened above we can observe the list of Home Manager +generations before and after the rollback:

$ home-manager generations
+2024-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation (current)
+2024-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation
+2024-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
+2023-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation
+2023-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation
 …
-
  • Copy the Nix store path of the generation you chose, e.g.,

    /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
    -

    for generation 763.

  • Run the activate script inside the copied store path:

    $ /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation/activate
    +
    +$ home-manager switch --rollback
     Starting home manager activation
     …
    -
  • + +$ home-manager generations +2024-01-04 11:56 : id 765 -> /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation +2024-01-03 10:29 : id 764 -> /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation (current) +2024-01-01 12:21 : id 763 -> /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation +2023-12-29 21:03 : id 762 -> /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation +2023-12-25 18:51 : id 761 -> /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation +… +

    Keeping your ~ safe from harm

    To configure programs and services Home Manager must write various things to your home directory. To prevent overwriting any existing files when switching to a new generation, Home Manager will attempt to detect @@ -952,6 +966,40 @@ use instead e.g.

    $ nix build --refer
     

    Some tests may be marked with enableLegacyIfd, those may be run by run with e.g.

    $ nix-build --pure tests --arg enableLegacyIfd true -A build.mytest
     
    +

    Home Manager Internals

    This chapter collects some documentation about the internal workings +of Home Manager. The information here is mostly aimed to developers of +Home Manager and those who do non-trivial integration with Home +Manager.

    Table of Contents

    Activation

    Activation

    Activating a Home Manager configuration ensures that the built +configuration is introduced into the user’s environment. The +activation is performed by a suitably named script +activate. This script is generated as part of the +configuration build and is placed in the root of the build output.

    The activation script is implemented in the Bash language and consists +of initialization code followed by a number of activation script +blocks. These blocks are specified using the +home.activation option. The blocks may have +dependencies among themselves and the generated activation script will +contain the blocks serialized such that the dependencies are +satisfied. A dependency cycle causes a failure when the configuration +is built.

    Historically, the activation script has been responsible for creating +a new generation of the home-manager Nix profile. The more modern +way, however, is to let the activation driver – that is, the +software calling the activation script – manage the profile. Indeed, +in some cases we may not have a home-manager profile at all! This is +the case when Home Manager is used as a NixOS or nix-darwin module, in +these cases the system profile will contain references to the +corresponding Home Manager configurations.

    Note, to maintain backwards compatibility, the old activation script +behavior is still the default. To choose the new mode of operation you +have to call the activation script with the command line option +--driver-version 1. The old behavior is available using +--driver-version 0, or simply omit it entirely.

    Unfortunately, driver software need to support both modes of operation +for the time being since a user may wish to activate an old generation +that contains an activation script that does not support +--driver-version. To determine whether support is available, check +the gen-version file in the configuration build output root. +If the file is missing then the activation script does not support +--driver-version. If the file exists and contains the integer 1 or +higher, then --driver-version 1 is supported.

    +

    Third-Party Tools and Extensions

    Here is a collection of tools and extensions that relate to Home Manager. Note, these are maintained outside the regular Home Manager flow so quality and support may vary wildly. If you encounter problems diff --git a/nix-darwin-options.xhtml b/nix-darwin-options.xhtml index 09f26f295..e84f30e67 100644 --- a/nix-darwin-options.xhtml +++ b/nix-darwin-options.xhtml @@ -27,6 +27,35 @@

    Appendix C. nix-darwin Configuration Options

    +
    + + home-manager.enableLegacyProfileManagement + + +
    +
    +

    Whether to enable legacy profile (and garbage collection root) +management during activation. When enabled, the Home Manager activation +will produce a per-user home-manager Nix profile as well as a garbage +collection root, just like in the standalone installation of Home +Manager. Typically, this is not desired when Home Manager is embedded in +the system configuration.

    + +

    Type: +boolean

    + +

    Default: +false

    + +

    Declared by:

    + + +
    + +<home-manager/nixos/common.nix> + +
    +
    home-manager.backupFileExtension diff --git a/nixos-options.xhtml b/nixos-options.xhtml index c89e0741a..a04ce676f 100644 --- a/nixos-options.xhtml +++ b/nixos-options.xhtml @@ -27,6 +27,35 @@

    Appendix B. NixOS Configuration Options

    +
    + + home-manager.enableLegacyProfileManagement + + +
    +
    +

    Whether to enable legacy profile (and garbage collection root) +management during activation. When enabled, the Home Manager activation +will produce a per-user home-manager Nix profile as well as a garbage +collection root, just like in the standalone installation of Home +Manager. Typically, this is not desired when Home Manager is embedded in +the system configuration.

    + +

    Type: +boolean

    + +

    Default: +false

    + +

    Declared by:

    + + +
    + +<home-manager/nixos/common.nix> + +
    +
    home-manager.backupFileExtension diff --git a/release-notes.xhtml b/release-notes.xhtml index 8bf2aaa9d..3f4603e84 100644 --- a/release-notes.xhtml +++ b/release-notes.xhtml @@ -26,7 +26,32 @@

    Appendix D. Release Notes

    This section lists the release notes for stable versions of Home Manager and the current unstable version.

    Release 25.11

    Table of Contents

    Highlights
    State Version Changes

    This is the current unstable branch and the information in this -section is therefore not final.

    Highlights

    This release has the following notable changes:

    • No changes.

    +section is therefore not final.

    Highlights

    This release has the following notable changes:

    • Updating the home-manager Nix profile inside the activation script +now deprecated. The profile update is instead the responsibility of +the software calling the activation script, such as the +home-manager tool.

      The legacy behavior remains the default for backwards compatibility +but may emit a deprecation warning in the future and in the longer +term removed all together. If you have developed tooling that +directly call the generated activation script, then you are +encouraged to adapt to the new behavior. See the +Activation section in the manual for +details on how to call the activation script.

    • The home-manager switch command now offers a --rollback option. +When given, the switch performs a rollback to the Home Manager +generation prior to the current before activating. While it was +previously possible to accomplish this by manually activating an old +generation, it always created a new profile generation. The new +behavior mirrors the behavior of nixos-rebuild switch --rollback. +See the Rollbacks section for more.

    • The home-manager switch command now offers a +--specialisation NAME option. When given, the switch activates the +named specialisation. While it was previously possible to accomplish +this by manually running the specialisation activate script it was +quite cumbersome and always created a new profile generation. The +new behavior mirrors the behavior of nixos-rebuild switch --specialisation.

    • When using Home Manager as a NixOS or nix-darwin module we +previously created an unnecessary home-manager per-user “shadow +profile” for the user. This no longer happens. You can restore the +old behavior by adding

      home-manager.enableLegacyProfileManagement = true;
      +

      to your configuration. This option is likely to be deprecated in the +future.

    State Version Changes

    The state version in this release includes the changes below. These changes are only active if the home.stateVersion option is set to "25.11" or later.

    • No changes.