home-manager/index.html

603 lines
87 KiB
HTML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Home Manager Manual</title><link rel="stylesheet" type="text/css" href="style.css" /><link rel="stylesheet" type="text/css" href="overrides.css" /><link rel="stylesheet" type="text/css" href="mono-blue.css" /><script src="highlight.pack.js" type="text/javascript"></script><script src="highlight.load.js" type="text/javascript"></script><meta name="generator" content="DocBook XSL Stylesheets V1.79.2" /><link rel="home" href="index.html" title="Home Manager Manual" /><link rel="next" href="options.html" title="Appendix A. Configuration Options" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Home Manager Manual</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="options.html">Next</a></td></tr></table><hr /></div><div class="book"><div class="titlepage"><div><div><h1 class="title"><a id="book-home-manager-manual"></a>Home Manager Manual</h1></div></div><hr /></div><div class="toc"><dl class="toc"><dt><span class="preface"><a href="index.html#idm140737328825312">Preface</a></span></dt><dt><span class="chapter"><a href="index.html#ch-installation">1. Installing Home Manager</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#sec-install-standalone">1.1. Standalone installation</a></span></dt><dt><span class="section"><a href="index.html#sec-install-nixos-module">1.2. NixOS module</a></span></dt><dt><span class="section"><a href="index.html#sec-install-nix-darwin-module">1.3. nix-darwin module</a></span></dt></dl></dd><dt><span class="chapter"><a href="index.html#ch-usage">2. Using Home Manager</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#sec-usage-configuration">2.1. Configuration Example</a></span></dt><dt><span class="section"><a href="index.html#sec-usage-rollbacks">2.2. Rollbacks</a></span></dt><dt><span class="section"><a href="index.html#sec-usage-dotfiles">2.3. Keeping your ~ safe from harm</a></span></dt><dt><span class="section"><a href="index.html#sec-usage-graphical">2.4. Graphical services</a></span></dt><dt><span class="section"><a href="index.html#sec-updating">2.5. Updating</a></span></dt></dl></dd><dt><span class="chapter"><a href="index.html#ch-nix-flakes">3. Nix Flakes</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#sec-flakes-prerequisties">3.1. Prerequisties</a></span></dt><dt><span class="section"><a href="index.html#sec-flakes-standalone">3.2. Standalone setup</a></span></dt><dt><span class="section"><a href="index.html#sec-flakes-nixos-module">3.3. NixOS module</a></span></dt><dt><span class="section"><a href="index.html#sec-flakes-nix-darwin-module">3.4. nix-darwin module</a></span></dt></dl></dd><dt><span class="chapter"><a href="index.html#ch-writing-modules">4. Writing Home Manager Modules</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#sec-option-types">4.1. Option Types</a></span></dt></dl></dd><dt><span class="chapter"><a href="index.html#ch-contributing">5. Contributing</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#sec-contrib-getting-started">5.1. Getting started</a></span></dt><dt><span class="section"><a href="index.html#sec-guidelines">5.2. Guidelines</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#sec-guidelines-back-compat">5.2.1. Maintain backward compatibility</a></span></dt><dt><span class="section"><a href="index.html#sec-guidelines-forward-compat">5.2.2. Keep forward compatibility in mind</a></span></dt><dt><span class="section"><a href="index.html#sec-guidelines-valuable-options">5.2.3. Add only valuable options</a></span></dt><dt><span class="section"><a href="index.html#sec-guidelines-add-tests">5.2.4. Add relevant tests</a></span></dt><dt><span class="
</a></span><span class="refpurpose"> — reconfigure a user environment</span></dt></dl></dd><dt><span class="appendix"><a href="release-notes.html">E. Release Notes</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-22.05">E.1. Release 22.05</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-22.05-highlights">E.1.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-22.05-state-version-changes">E.1.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-21.11">E.2. Release 21.11</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-21.11-highlights">E.2.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-21.11-state-version-changes">E.2.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-21.05">E.3. Release 21.05</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-21.05-highlights">E.3.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-21.05-state-version-changes">E.3.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-20.09">E.4. Release 20.09</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-20.09-highlights">E.4.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-20.09-state-version-changes">E.4.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-20.03">E.5. Release 20.03</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-20.03-highlights">E.5.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-20.03-state-version-changes">E.5.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-19.09">E.6. Release 19.09</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-19.09-highlights">E.6.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-19.09-state-version-changes">E.6.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-19.03">E.7. Release 19.03</a></span></dt><dd><dl><dt><span class="section"><a href="release-notes.html#sec-release-19.03-highlights">E.7.1. Highlights</a></span></dt><dt><span class="section"><a href="release-notes.html#sec-release-19.03-state-version-changes">E.7.2. State Version Changes</a></span></dt></dl></dd><dt><span class="section"><a href="release-notes.html#sec-release-18.09">E.8. Release 18.09</a></span></dt></dl></dd></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a id="idm140737328825312"></a>Preface</h1></div></div></div><p>
This manual will eventually describe how to install, use, and extend Home
Manager.
</p><p>
If you encounter problems then please reach out on the IRC channel
<a class="link" href="https://webchat.oftc.net/?channels=home-manager" target="_top">#home-manager</a>
hosted by <a class="link" href="https://oftc.net/" target="_top">OFTC</a>.
There is also a <a class="link" href="https://matrix.to/#/%23hm:rycee.net" target="_top">Matrix room</a>,
which is bridged to the IRC channel.
If your problem is caused by a bug in Home Manager then it should
be reported on the
<a class="link" href="https://github.com/nix-community/home-manager/issues" target="_top">Home Manager issue tracker</a>.
</p><div class="note"><h3 class="title">Note</h3><p>
Commands prefixed with <code class="literal">#</code> have to be run as root, either
requiring to login as root user or temporarily switching to it using
<code class="literal">sudo</code> for example.
</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="ch-installation"></a>Chapter 1. Installing Home Manager</h1></div></div></div><p>Home Manager can be used in three primary ways:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
Using the standalone <code class="literal">home-manager</code> 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
<a class="xref" href="index.html#sec-install-standalone" title="1.1. Standalone installation">Section 1.1, “Standalone installation”</a> for instructions on how to perform this
installation.
</li><li class="listitem">
As a module within a NixOS system configuration. This allows the
user profiles to be built together with the system when running
<code class="literal">nixos-rebuild</code>. See <a class="xref" href="index.html#sec-install-nixos-module" title="1.2. NixOS module">Section 1.2, “NixOS module”</a> for a description of
this setup.
</li><li class="listitem">
As a module within a <a class="link" href="https://github.com/LnL7/nix-darwin/" target="_top">nix-darwin</a> system configuration.
This allows the user profiles to be built together with the system
when running <code class="literal">darwin-rebuild</code>. See <a class="xref" href="index.html#sec-install-nix-darwin-module" title="1.3. nix-darwin module">Section 1.3, “nix-darwin module”</a>
for a description of this setup.
</li></ol></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-install-standalone"></a>1.1. Standalone installation</h2></div></div></div><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">
Make sure you have a working Nix installation. Specifically, make
sure that your user is able to build and install Nix packages. For
example, you should be able to successfully run a command like
<code class="literal">nix-instantiate '&lt;nixpkgs&gt;' -A hello</code> without having to switch to the
root user. For a multi-user install of Nix this means that your user
must be covered by the <a class="link" href="https://nixos.org/nix/manual/#conf-allowed-users" target="_top"><code class="literal">allowed-users</code></a> Nix
option. On NixOS you can control this option using the
<a class="link" href="https://nixos.org/nixos/manual/options.html#opt-nix.allowedUsers" target="_top"><code class="literal">nix.allowedUsers</code></a> system option.
</p><p class="simpara">Note that Nix 2.4 is not yet fully supported. Most significantly, Home
Manager is incompatible with the new <code class="literal">nix profile</code>.</p></li><li class="listitem"><p class="simpara">
Add the appropriate Home Manager channel. If you are following
Nixpkgs master or an unstable channel you can run
</p><pre class="programlisting console">$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
$ nix-channel --update</pre><p class="simpara">and if you follow a Nixpkgs version 21.11 channel you can run</p><pre class="programlisting console">$ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager
$ nix-channel --update</pre><p class="simpara">On non-NixOS, you may have to add</p><pre class="programlisting bash">export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH}</pre><p class="simpara">to your shell (see <a class="link" href="https://github.com/NixOS/nix/issues/2033" target="_top">nix#2033</a>
and
<a class="link" href="https://discourse.nixos.org/t/where-is-nix-path-supposed-to-be-set/16434/8" target="_top">this
reply on the Nix Discourse</a>).</p></li><li class="listitem"><p class="simpara">
Run the Home Manager installation command and create the first Home
Manager generation:
</p><pre class="programlisting console">$ nix-shell '&lt;home-manager&gt;' -A install</pre><p class="simpara">Once finished, Home Manager should be active and available in your
user environment.</p></li><li class="listitem"><p class="simpara">
If you do not plan on having Home Manager manage your shell
configuration then you must source the
</p><pre class="programlisting bash">$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh</pre><p class="simpara">file in your shell configuration. Alternatively source</p><pre class="programlisting bash">/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh</pre><p class="simpara">when managing home configuration together with system configuration.</p><p class="simpara">This file can be sourced directly by POSIX.2-like shells such as
<a class="link" href="https://www.gnu.org/software/bash/" target="_top">Bash</a> or <a class="link" href="http://zsh.sourceforge.net/" target="_top">Z shell</a>. <a class="link" href="https://fishshell.com" target="_top">Fish</a> users can use utilities
such as <a class="link" href="https://github.com/oh-my-fish/plugin-foreign-env" target="_top">foreign-env</a> or <a class="link" href="https://github.com/bouk/babelfish" target="_top">babelfish</a>.</p><p class="simpara">For example, if you use Bash then add</p><pre class="programlisting bash">. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"</pre><p class="simpara">to your <code class="literal">~/.profile</code> file.</p></li></ol></div><p>If instead of using channels you want to run Home Manager from a Git
checkout of the repository then you can use the
<a class="xref" href="options.html#opt-programs.home-manager.path"><code class="option">programs.home-manager.path</code></a> option to specify the absolute path
to the repository.</p><p>Once installed you can see <a class="xref" href="index.html#ch-usage" title="Chapter 2. Using Home Manager">Chapter 2, <em>Using Home Manager</em></a> for a more detailed
description of Home Manager and how to use it.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-install-nixos-module"></a>1.2. NixOS module</h2></div></div></div><p>Home Manager provides a NixOS module that allows you to prepare user
environments directly from the system configuration file, which often
is more convenient than using the <code class="literal">home-manager</code> tool. It also opens
up additional possibilities, for example, to automatically configure
user environments in NixOS declarative containers or on systems
deployed through NixOps.</p><p>To make the NixOS module available for use you must <code class="literal">import</code> it into
your system configuration. This is most conveniently done by adding a
Home Manager channel. For example, if you are following Nixpkgs master
or an unstable channel, you can run</p><pre class="programlisting console"># nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
# nix-channel --update</pre><p>and if you follow a Nixpkgs version 21.11 channel, you can run</p><pre class="programlisting console"># nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager
# nix-channel --update</pre><p>It is then possible to add</p><pre class="programlisting nix">imports = [ &lt;home-manager/nixos&gt; ];</pre><p>to your system <code class="literal">configuration.nix</code> file, which will introduce a new
NixOS option called <code class="literal">home-manager.users</code> whose type is an attribute
set that maps user names to Home Manager configurations.</p><p>For example, a NixOS configuration may include the lines</p><pre class="programlisting nix">users.users.eve.isNormalUser = true;
home-manager.users.eve = { pkgs, ... }: {
home.packages = [ pkgs.atool pkgs.httpie ];
programs.bash.enable = true;
};</pre><p>and after a <code class="literal">nixos-rebuild switch</code> the user eves environment should
include a basic Bash configuration and the packages atool and httpie.</p><div class="note"><h3 class="title">Note</h3><p>If <code class="literal">nixos-rebuild switch</code> does not result in the environment you expect,
you can take a look at the output of the Home Manager activation script output using</p><pre class="programlisting console">$ systemctl status "home-manager-$USER.service"</pre></div><p>If you do not plan on having Home Manager manage your shell
configuration then you must add either</p><pre class="programlisting bash">. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"</pre><p>or</p><pre class="programlisting bash">. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh"</pre><p>to your shell configuration, depending on whether
<a class="xref" href="nixos-options.html#nixos-opt-home-manager.useUserPackages"><code class="option">home-manager.useUserPackages</code></a> is enabled. This file can
be sourced directly by POSIX.2-like shells such as <a class="link" href="https://www.gnu.org/software/bash/" target="_top">Bash</a> or
<a class="link" href="http://zsh.sourceforge.net/" target="_top">Z shell</a>. <a class="link" href="https://fishshell.com" target="_top">Fish</a> users can use utilities such as
<a class="link" href="https://github.com/oh-my-fish/plugin-foreign-env" target="_top">foreign-env</a> or <a class="link" href="https://github.com/bouk/babelfish" target="_top">babelfish</a>.</p><div class="note"><h3 class="title">Note</h3><p>By default packages will be installed to <code class="literal">$HOME/.nix-profile</code> but they
can be installed to <code class="literal">/etc/profiles</code> if</p><pre class="programlisting nix">home-manager.useUserPackages = true;</pre><p>is added to the system configuration. This is necessary if, for
example, you wish to use <code class="literal">nixos-rebuild build-vm</code>. This option may
become the default value in the future.</p></div><div class="note"><h3 class="title">Note</h3><p>By default, Home Manager uses a private <code class="literal">pkgs</code> instance that is
configured via the <code class="literal">home-manager.users.&lt;name&gt;.nixpkgs</code> options. To
instead use the global <code class="literal">pkgs</code> that is configured via the system level
<code class="literal">nixpkgs</code> options, set</p><pre class="programlisting nix">home-manager.useGlobalPkgs = true;</pre><p>This saves an extra Nixpkgs evaluation, adds consistency, and removes
the dependency on <code class="literal">NIX_PATH</code>, which is otherwise used for importing
Nixpkgs.</p></div><p>Once installed you can see <a class="xref" href="index.html#ch-usage" title="Chapter 2. Using Home Manager">Chapter 2, <em>Using Home Manager</em></a> for a more detailed
description of Home Manager and how to use it.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-install-nix-darwin-module"></a>1.3. nix-darwin module</h2></div></div></div><p>Home Manager provides a module that allows you to prepare user
environments directly from the <a class="link" href="https://github.com/LnL7/nix-darwin/" target="_top">nix-darwin</a> configuration
file, which often is more convenient than using the <code class="literal">home-manager</code>
tool.</p><p>To make the NixOS module available for use you must <code class="literal">import</code> it into
your system configuration. This is most conveniently done by adding a
Home Manager channel. For example, if you are following Nixpkgs master
or an unstable channel, you can run</p><pre class="programlisting console"># nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
# nix-channel --update</pre><p>and if you follow a Nixpkgs version 21.11 channel, you can run</p><pre class="programlisting console"># nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.11.tar.gz home-manager
# nix-channel --update</pre><p>It is then possible to add</p><pre class="programlisting nix">imports = [ &lt;home-manager/nix-darwin&gt; ];</pre><p>to your nix-darwin <code class="literal">configuration.nix</code> file, which will introduce a
new NixOS option called <code class="literal">home-manager</code> whose type is an attribute set
that maps user names to Home Manager configurations.</p><p>For example, a nix-darwin configuration may include the lines</p><pre class="programlisting nix">users.users.eve = {
name = "eve";
home = "/Users/eve";
}
home-manager.users.eve = { pkgs, ... }: {
home.packages = [ pkgs.atool pkgs.httpie ];
programs.bash.enable = true;
};</pre><p>and after a <code class="literal">darwin-rebuild switch</code> the user eves environment
should include a basic Bash configuration and the packages atool and
httpie.</p><p>If you do not plan on having Home Manager manage your shell
configuration then you must add either</p><pre class="programlisting bash">. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"</pre><p>or</p><pre class="programlisting bash">. "/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh"</pre><p>to your shell configuration, depending on whether
<a class="xref" href="nix-darwin-options.html#nix-darwin-opt-home-manager.useUserPackages"><code class="option">home-manager.useUserPackages</code></a> is enabled. This file
can be sourced directly by POSIX.2-like shells such as <a class="link" href="https://www.gnu.org/software/bash/" target="_top">Bash</a> or
<a class="link" href="http://zsh.sourceforge.net/" target="_top">Z shell</a>. <a class="link" href="https://fishshell.com" target="_top">Fish</a> users can use utilities such as
<a class="link" href="https://github.com/oh-my-fish/plugin-foreign-env" target="_top">foreign-env</a> or <a class="link" href="https://github.com/bouk/babelfish" target="_top">babelfish</a>.</p><div class="note"><h3 class="title">Note</h3><p>By default user packages will not be ignored in favor of
<code class="literal">environment.systemPackages</code>, but they will be intalled to
<code class="literal">/etc/profiles/per-user/$USERNAME</code> if</p><pre class="programlisting nix">home-manager.useUserPackages = true;</pre><p>is added to the nix-darwin configuration. This option may become the
default value in the future.</p></div><div class="note"><h3 class="title">Note</h3><p>By default, Home Manager uses a private <code class="literal">pkgs</code> instance that is
configured via the <code class="literal">home-manager.users.&lt;name&gt;.nixpkgs</code> options. To
instead use the global <code class="literal">pkgs</code> that is configured via the system level
<code class="literal">nixpkgs</code> options, set</p><pre class="programlisting nix">home-manager.useGlobalPkgs = true;</pre><p>This saves an extra Nixpkgs evaluation, adds consistency, and removes
the dependency on <code class="literal">NIX_PATH</code>, which is otherwise used for importing
Nixpkgs.</p></div><p>Once installed you can see <a class="xref" href="index.html#ch-usage" title="Chapter 2. Using Home Manager">Chapter 2, <em>Using Home Manager</em></a> for a more detailed
description of Home Manager and how to use it.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="ch-usage"></a>Chapter 2. Using Home Manager</h1></div></div></div><p>Your use of Home Manager is centered around the configuration file, which is typically found at <code class="literal">~/.config/nixpkgs/home.nix</code>.</p><p>This configuration file can be <span class="emphasis"><em>built</em></span> and <span class="emphasis"><em>activated</em></span>.</p><p>Building a configuration produces a directory in the Nix store that contains all files and programs that should be available in your home directory and Nix user profile, respectively. The build step also checks that the configuration is valid and it will fail with an error if you, for example, assign a value to an option that does not exist or assign a value of the wrong type. Some modules also have custom assertions that perform more detailed, module specific, checks.</p><p>Concretely, if your configuration contains</p><pre class="programlisting nix">programs.emacs.enable = "yes";</pre><p>then building it, for example using <code class="literal">home-manager build</code>, will result in an error message saying something like</p><pre class="programlisting console">$ home-manager build
error: A definition for option `programs.emacs.enable' is not of type `boolean'. Definition values:
- In `/home/jdoe/.config/nixpkgs/home.nix': "yes"
(use '--show-trace' to show detailed location information)</pre><p>The message indicates that you must provide a Boolean value for this option, that is, either <code class="literal">true</code> or <code class="literal">false</code>. The documentation of each option will state the expected type, for <a class="xref" href="options.html#opt-programs.emacs.enable"><code class="option">programs.emacs.enable</code></a> you will see “Type: boolean”. You there also find information about the default value and a description of the option. You can find the complete option documentation in <a class="xref" href="options.html" title="Appendix A. Configuration Options">Appendix A, <em>Configuration Options</em></a> or directly in the terminal by running</p><pre class="programlisting console">man home-configuration.nix</pre><p>Once a configuration is successfully built, it can be activated. The activation performs the steps necessary to make the files, programs, and services available in your user environment. The <code class="literal">home-manager switch</code> command performs a combined build and activation.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-usage-configuration"></a>2.1. Configuration Example</h2></div></div></div><p>A fresh install of Home Manager will generate a minimal <code class="literal">~/.config/nixpkgs/home.nix</code> file containing something like</p><pre class="programlisting nix">{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "jdoe";
home.homeDirectory = "/home/jdoe";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.05";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}</pre><p>You can use this as a base for your further configurations.</p><div class="note"><h3 class="title">Note</h3><p>If you are not very familiar with the Nix language and NixOS modules then it is encouraged to start with small and simple changes. As you learn you can gradually grow the configuration with confidence.</p></div><p>As an example, let us expand the initial configuration file to also install the htop and fortune packages, install Emacs with a few extra packages available, and enable the user gpg-agent service.</p><p>To satisfy the above setup we should elaborate the <code class="literal">home.nix</code> file as follows:</p><pre class="programlisting nix">{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "jdoe";
home.homeDirectory = "/home/jdoe";
# Packages that should be installed to the user profile.
home.packages = [ <a id="CO1-1"></a><span><img src="images/callouts/1.svg" alt="1" border="0" /></span>
pkgs.htop
pkgs.fortune
];
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.05";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.emacs = { <a id="CO1-2"></a><span><img src="images/callouts/2.svg" alt="2" border="0" /></span>
enable = true;
extraPackages = epkgs: [
epkgs.nix-mode
epkgs.magit
];
};
services.gpg-agent = { <a id="CO1-3"></a><span><img src="images/callouts/3.svg" alt="3" border="0" /></span>
enable = true;
defaultCacheTtl = 1800;
enableSshSupport = true;
};
}</pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-1"><span><img src="images/callouts/1.svg" alt="1" border="0" /></span></a> </p></td><td valign="top" align="left"><p>
Nixpkgs packages can be installed to the user profile using <a class="xref" href="options.html#opt-home.packages"><code class="option">home.packages</code></a>.
</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-2"><span><img src="images/callouts/2.svg" alt="2" border="0" /></span></a> </p></td><td valign="top" align="left"><p>
The option names of a program module typically start with <code class="literal">programs.&lt;package name&gt;</code>.
</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-3"><span><img src="images/callouts/3.svg" alt="3" border="0" /></span></a> </p></td><td valign="top" align="left"><p>
Similarly, for a service module, the names start with <code class="literal">services.&lt;package name&gt;</code>. Note in some cases a package has both programs <span class="emphasis"><em>and</em></span> service options Emacs is such an example.
</p></td></tr></table></div><p>To activate this configuration you can run</p><pre class="programlisting console">home-manager switch</pre><p>or if you are not feeling so lucky,</p><pre class="programlisting console">home-manager build</pre><p>which will create a <code class="literal">result</code> link to a directory containing an
activation script and the generated home directory files.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-usage-rollbacks"></a>2.2. Rollbacks</h2></div></div></div><p>While the <code class="literal">home-manager</code> tool does not explicitly support rollbacks at the moment it is relatively easy to perform one manually. The steps to do so are</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">
Run <code class="literal">home-manager generations</code> to determine which generation you wish to rollback to:
</p><pre class="programlisting console">$ home-manager generations
2018-01-04 11:56 : id 765 -&gt; /nix/store/kahm1rxk77mnvd2l8pfvd4jkkffk5ijk-home-manager-generation
2018-01-03 10:29 : id 764 -&gt; /nix/store/2wsmsliqr5yynqkdyjzb1y57pr5q2lsj-home-manager-generation
2018-01-01 12:21 : id 763 -&gt; /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation
2017-12-29 21:03 : id 762 -&gt; /nix/store/6c0k1r03fxckql4vgqcn9ccb616ynb94-home-manager-generation
2017-12-25 18:51 : id 761 -&gt; /nix/store/czc5y6vi1rvnkfv83cs3rn84jarcgsgh-home-manager-generation
</pre></li><li class="listitem"><p class="simpara">
Copy the Nix store path of the generation you chose, e.g.,
</p><pre class="screen">/nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation</pre><p class="simpara">for generation 763.</p></li><li class="listitem"><p class="simpara">
Run the <code class="literal">activate</code> script inside the copied store path:
</p><pre class="programlisting console">$ /nix/store/mv960kl9chn2lal5q8lnqdp1ygxngcd1-home-manager-generation/activate
Starting home manager activation
</pre></li></ol></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-usage-dotfiles"></a>2.3. Keeping your ~ safe from harm</h2></div></div></div><p>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 collisions between existing files and generated files. If any such collision is detected the activation will terminate before changing anything on your computer.</p><p>For example, suppose you have a wonderful, painstakingly created <code class="literal">~/.config/git/config</code> and add</p><pre class="programlisting nix">{
# …
programs.git = {
enable = true;
userName = "Jane Doe";
userEmail = "jane.doe@example.org";
};
# …
}</pre><p>to your configuration. Attempting to switch to the generation will then result in</p><pre class="programlisting console">$ home-manager switch
Activating checkLinkTargets
Existing file '/home/jdoe/.config/git/config' is in the way
Please move the above files and try again</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-usage-graphical"></a>2.4. Graphical services</h2></div></div></div><p>Home Manager includes a number of services intended to run in a graphical session, for example <code class="literal">xscreensaver</code> and <code class="literal">dunst</code>. Unfortunately, such services will not be started automatically unless you let Home Manager start your X session. That is, you have something like</p><pre class="programlisting nix">{
# …
services.xserver.enable = true;
# …
}</pre><p>in your system configuration and</p><pre class="programlisting nix">{
# …
xsession.enable = true;
xsession.windowManager.command = "…";
# …
}</pre><p>in your Home Manager configuration.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-updating"></a>2.5. Updating</h2></div></div></div><p>If you have installed Home Manager using the Nix channel method
then updating Home Manager is done by first updating the channel.
You can then switch to the updated Home Manager environment.</p><pre class="programlisting console">$ nix-channel --update
unpacking channels...
$ home-manager switch</pre></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="ch-nix-flakes"></a>Chapter 3. Nix Flakes</h1></div></div></div><p>Home Manager includes a <code class="literal">flake.nix</code> file for compatibility with <a class="link" href="https://nixos.wiki/wiki/Flakes" target="_top">Nix Flakes</a>.
The support is still experimental and may change in backwards incompatible ways.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-flakes-prerequisties"></a>3.1. Prerequisties</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Install Nix 2.4 or have it in <code class="literal">nix-shell</code>.
</li><li class="listitem"><p class="simpara">
Enable experimental features <code class="literal">nix-command</code> and <code class="literal">flakes</code>.
</p><p class="simpara">Either set in <code class="literal">nix.conf</code></p><pre class="programlisting bash">experimental-features = nix-command flakes</pre><p class="simpara">or pass them to <code class="literal">nix</code> and <code class="literal">home-manager</code> by</p><pre class="programlisting console">$ nix --extra-experimental-features "nix-command flakes" &lt;sub-commands&gt;
$ home-manager --extra-experimental-features "nix-command flakes" &lt;sub-commands&gt;</pre></li><li class="listitem"><p class="simpara">
Prepare your Home Manager configuration (<code class="literal">home.nix</code>).
</p><p class="simpara">Unlike the channel-based setup,
<code class="literal">home.nix</code> will be evaluated when the flake is built,
so it must be present before bootstrap of Home Manager from the flake.
See <a class="xref" href="index.html#sec-usage-configuration" title="2.1. Configuration Example">Section 2.1, “Configuration Example”</a> for introduction about
writing a Home Manager configuration.</p><div class="note"><h3 class="title">Note</h3><p>The <code class="literal">stateVersion</code> will be specified in the flake instead of in the configuration file.</p><p>Remove the line containing <code class="literal">home.stateVersion</code> in the example.</p></div></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-flakes-standalone"></a>3.2. Standalone setup</h2></div></div></div><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">
Set up a flake with a <code class="literal">flake.nix</code> as follows:
</p><pre class="programlisting nix">{
description = "Home Manager configuration of Jane Doe";
inputs = {
# Specify the source of Home Manager and Nixpkgs
home-manager.url = "github:nix-community/home-manager";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { home-manager, ... }:
let
system = "x86_64-linux";
username = "jdoe";
in {
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
# Specify the path to your home configuration here
configuration = import ./home.nix;
inherit system username;
homeDirectory = "/home/${username}";
# Update the state version as needed.
# See the changelog here:
# https://nix-community.github.io/home-manager/release-notes.html#sec-release-21.05
stateVersion = "21.11";
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}</pre><div class="note"><h3 class="title">Note</h3><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
The above example tracks the master branch of Home Manager
and nixos-unstable branch of Nixpkgs.
If you would like to use the <code class="literal">release-21.11</code> branch,
change the <code class="literal">home-manager</code> input url to <code class="literal">github:nix-community/home-manager/release-21.11</code>
and <code class="literal">nixpkgs</code> url to <code class="literal">github:NixOS/nixpkgs/nixos-21.11</code>.
Make sure to also update to the <code class="literal">stateVersion</code> option accordingly.
</li><li class="listitem">
The Home Manager library is exported by the flake under
<code class="literal">lib.hm</code>.
</li></ul></div></div></li><li class="listitem"><p class="simpara">
Install Home Manager and apply the configuration by
</p><pre class="programlisting console">$ nix build --no-link &lt;flake-uri&gt;#homeConfigurations.jdoe.activationPackage
$ "$(nix path-info &lt;flake-uri&gt;#homeConfigurations.jdoe.activationPackage)"/activate</pre><p class="simpara">Substitute <code class="literal">&lt;flake-uri&gt;</code> with the flake URI of the configuration flake.
If <code class="literal">flake.nix</code> resides in <code class="literal">~/.config/nixpkgs</code>,
<code class="literal">&lt;flake-uri&gt;</code> may be <code class="literal">~/.config/nixpkgs</code>
as a Git tree or <code class="literal">path:~/.config/nixpkgs</code> if not.</p></li><li class="listitem"><p class="simpara">
Since the release <code class="literal">21.05</code>,
building a flake-based configuration is as simple as
</p><pre class="programlisting console">$ home-manager switch --flake '&lt;flake-uri&gt;#jdoe'</pre><p class="simpara">once home-manager is installed.</p><p class="simpara">Here, <code class="literal">jdoe</code> is a configuration specified in the flake file,
and <code class="literal">&lt;flake-uri&gt;#jdoe</code> will be expanded to
<code class="literal">&lt;flake-uri&gt;#homeConfigurations.jdoe.activationPackage</code>
and be built by Nix.</p></li></ol></div><div class="note"><h3 class="title">Note</h3><p>The flake inputs are not upgraded automatically when switching.
The analogy to the command <code class="literal">home-manager --update ...</code> is <code class="literal">nix flake update</code>.</p><p>If updating more than one input is undesirable,
the command <code class="literal">nix flake lock --update-input &lt;input-name&gt;</code> can be used.</p><p>You can also pass flake-related options
such as <code class="literal">--recreate-lock-file</code> or <code class="literal">--update-input [input]</code>
to <code class="literal">home-manager</code> when building/switching,
and these options will be forwarded to <code class="literal">nix build</code>.
See the <a class="link" href="https://nixos.wiki/wiki/Flakes" target="_top">NixOS Wiki page</a> for detail.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-flakes-nixos-module"></a>3.3. NixOS module</h2></div></div></div><p>To use Home Manager as a NixOS module,
a bare-minimum <code class="literal">flake.nix</code> would be as follows:</p><pre class="programlisting nix">{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ nixpkgs, home-manager, ... }: {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jdoe = import ./home.nix;
# Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix
}
];
};
};
};
}</pre><p>The Home Manager configuration is then part of the NixOS configuration
and is automatically rebuilt with the system when using the appropriate command
for the system, such as <code class="literal">nixos-rebuild switch --flake &lt;flake-uri&gt;</code>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-flakes-nix-darwin-module"></a>3.4. nix-darwin module</h2></div></div></div><p>The flake-based setup of the Home Manager nix-darwin module
is similar to that of NixOS. The <code class="literal">flake.nix</code> would be:</p><pre class="programlisting nix">{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ nixpkgs, home-manager, nix-darwin, ... }: {
darwinConfigurations = {
hostname = nix-darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
./configuration.nix
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jdoe = import ./home.nix;
# Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix
}
];
};
};
};
}</pre><p>and it is also rebuilt with the nix-darwin generations.
The rebuild command here may be <code class="literal">darwin-rebuild switch --flake &lt;flake-uri&gt;</code>.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="ch-writing-modules"></a>Chapter 4. Writing Home Manager Modules</h1></div></div></div><p>The module system in Home Manager is based entirely on the NixOS module system so we will here only highlight aspects that are specific for Home Manager. For information about the module system as such please refer to the <a class="link" href="https://nixos.org/nixos/manual/index.html#sec-writing-modules" target="_top">Writing NixOS Modules</a> chapter of the NixOS manual.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-option-types"></a>4.1. Option Types</h2></div></div></div><p>Overall the basic option types are the same in Home Manager as NixOS. A few Home Manager options, however, make use of custom types that are worth describing in more detail. These are the option types <code class="literal">dagOf</code> and <code class="literal">gvariant</code> that are used, for example, by <a class="xref" href="options.html#opt-programs.ssh.matchBlocks"><code class="option">programs.ssh.matchBlocks</code></a> and <a class="xref" href="options.html#opt-dconf.settings"><code class="option">dconf.settings</code></a>.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<code class="literal">hm.types.dagOf</code>
</span></dt><dd><p class="simpara">
Options of this type have attribute sets as values where each member is a node in a <a class="link" href="https://en.wikipedia.org/w/index.php?title=Directed_acyclic_graph&amp;oldid=939656095" target="_top">directed acyclic graph</a> (DAG). This allows the attribute set entries to express dependency relations among themselves. This can, for example, be used to control the order of match blocks in a OpenSSH client configuration or the order of activation script blocks in <a class="xref" href="options.html#opt-home.activation"><code class="option">home.activation</code></a>.
</p><p class="simpara">A number of functions are provided to create DAG nodes. The functions are shown below with examples using an option <code class="literal">foo.bar</code> of type <code class="literal">hm.types.dagOf types.int</code>.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<code class="literal">hm.dag.entryAnywhere (value: T)</code>
</span></dt><dd><p class="simpara">
Indicates that <code class="literal">value</code> can be placed anywhere within the DAG. This is also the default for plain attribute set entries, that is
</p><pre class="programlisting nix">foo.bar = {
a = hm.dag.entryAnywhere 0;
}</pre><p class="simpara">and</p><pre class="programlisting nix">foo.bar = {
a = 0;
}</pre><p class="simpara">are equivalent.</p></dd><dt><span class="term">
<code class="literal">hm.dag.entryAfter (afters: list string) (value: T)</code>
</span></dt><dd><p class="simpara">
Indicates that <code class="literal">value</code> must be placed <span class="emphasis"><em>after</em></span> each of the attribute names in the given list. For example
</p><pre class="programlisting nix">foo.bar = {
a = 0;
b = hm.dag.entryAfter [ "a" ] 1;
}</pre><p class="simpara">would place <code class="literal">b</code> after <code class="literal">a</code> in the graph.</p></dd><dt><span class="term">
<code class="literal">hm.dag.entryBefore (befores: list string) (value: T)</code>
</span></dt><dd><p class="simpara">
Indicates that <code class="literal">value</code> must be placed <span class="emphasis"><em>before</em></span> each of the attribute names in the given list. For example
</p><pre class="programlisting nix">foo.bar = {
b = hm.dag.entryBefore [ "a" ] 1;
a = 0;
}</pre><p class="simpara">would place <code class="literal">b</code> before <code class="literal">a</code> in the graph.</p></dd><dt><span class="term">
<code class="literal">hm.dag.entryBetween (befores: list string) (afters: list string) (value: T)</code>
</span></dt><dd><p class="simpara">
Indicates that <code class="literal">value</code> must be placed <span class="emphasis"><em>before</em></span> the attribute names in the first list and <span class="emphasis"><em>after</em></span> the attribute names in the second list. For example
</p><pre class="programlisting nix">foo.bar = {
a = 0;
c = hm.dag.entryBetween [ "b" ] [ "a" ] 2;
b = 1;
}</pre><p class="simpara">would place <code class="literal">c</code> before <code class="literal">b</code> and after <code class="literal">a</code> in the graph.</p></dd></dl></div></dd><dt><span class="term">
<code class="literal">hm.types.gvariant</code>
</span></dt><dd><p class="simpara">
This type is useful for options representing <a class="link" href="https://developer.gnome.org/glib/stable/glib-GVariant.html#glib-GVariant.description" target="_top">GVariant</a> values. The type accepts all primitive GVariant types as well as arrays and tuples. Dictionaries are not currently supported.
</p><p class="simpara">To create a GVariant value you can use a number of provided functions. Examples assume an option <code class="literal">foo.bar</code> of type <code class="literal">hm.types.gvariant</code>.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<code class="literal">hm.gvariant.mkBoolean (v: bool)</code>
</span></dt><dd><p class="simpara">
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">boolean</code> value. Note, Nix booleans are automatically coerced using this function. That is,
</p><pre class="programlisting nix">foo.bar = hm.gvariant.mkBoolean true;</pre><p class="simpara">is equivalent to</p><pre class="programlisting nix">foo.bar = true;</pre></dd><dt><span class="term">
<code class="literal">hm.gvariant.mkString (v: string)</code>
</span></dt><dd><p class="simpara">
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">string</code> value. Note, Nix strings are automatically coerced using this function. That is,
</p><pre class="programlisting nix">foo.bar = hm.gvariant.mkString "a string";</pre><p class="simpara">is equivalent to</p><pre class="programlisting nix">foo.bar = "a string";</pre></dd><dt><span class="term">
<code class="literal">hm.gvariant.mkObjectpath (v: string)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">objectpath</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkUchar (v: string)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">uchar</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkInt16 (v: int)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">int16</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkUint16 (v: int)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">uint16</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkInt32 (v: int)</code>
</span></dt><dd><p class="simpara">
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">int32</code> value. Note, Nix integers are automatically coerced using this function. That is,
</p><pre class="programlisting nix">foo.bar = hm.gvariant.mkInt32 7;</pre><p class="simpara">is equivalent to</p><pre class="programlisting nix">foo.bar = 7;</pre></dd><dt><span class="term">
<code class="literal">hm.gvariant.mkUint32 (v: int)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">uint32</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkInt64 (v: int)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">int64</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkUint64 (v: int)</code>
</span></dt><dd>
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">uint64</code> value.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkDouble (v: double)</code>
</span></dt><dd><p class="simpara">
Takes a Nix value <code class="literal">v</code> to a GVariant <code class="literal">double</code> value. Note, Nix floats are automatically coerced using this function. That is,
</p><pre class="programlisting nix">foo.bar = hm.gvariant.mkDouble 3.14;</pre><p class="simpara">is equivalent to</p><pre class="programlisting nix">foo.bar = 3.14;</pre></dd><dt><span class="term">
<code class="literal">hm.gvariant.mkArray type elements</code>
</span></dt><dd><p class="simpara">
Builds a GVariant array containing the given list of elements, where each element is a GVariant value of the given type. The <code class="literal">type</code> value can be constructed using
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<code class="literal">hm.gvariant.type.string</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.boolean</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.uchar</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.int16</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.uint16</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.int32</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.uint32</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.int64</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.uint64</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.double</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.arrayOf type</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.maybeOf type</code>
</li><li class="listitem">
<code class="literal">hm.gvariant.type.tupleOf types</code>
</li></ul></div><p class="simpara">where <code class="literal">type</code> and <code class="literal">types</code> are themselves a type and list of types, respectively.</p></dd><dt><span class="term">
<code class="literal">hm.gvariant.mkEmptyArray type</code>
</span></dt><dd>
An alias of <code class="literal">hm.gvariant.mkArray type []</code>.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkNothing type</code>
</span></dt><dd>
Builds a GVariant maybe value whose (non-existent) element is of the given type. The <code class="literal">type</code> value is constructed as described for the <code class="literal">mkArray</code> function above.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkJust element</code>
</span></dt><dd>
Builds a GVariant maybe value containing the given GVariant element.
</dd><dt><span class="term">
<code class="literal">hm.gvariant.mkTuple elements</code>
</span></dt><dd>
Builds a GVariant tuple containing the given list of elements, where each element is a GVariant value.
</dd></dl></div></dd></dl></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="ch-contributing"></a>Chapter 5. Contributing</h1></div></div></div><p>Contributions to Home Manager are very welcome. To make the process as smooth as possible for both you and the Home Manager maintainers we provide some guidelines that we ask you to follow. See <a class="xref" href="index.html#sec-contrib-getting-started" title="5.1. Getting started">Section 5.1, “Getting started”</a> for information on how to set up a suitable development environment and <a class="xref" href="index.html#sec-guidelines" title="5.2. Guidelines">Section 5.2, “Guidelines”</a> for the actual guidelines.</p><p>This text is mainly directed at those who would like to make code contributions to Home Manager. If you just want to report a bug then first look among the already <a class="link" href="https://github.com/nix-community/home-manager/issues" target="_top">open issues</a>, if you find one matching yours then feel free to comment on it to add any additional information you may have. If no matching issue exists then go to the <a class="link" href="https://github.com/nix-community/home-manager/issues/new" target="_top">new issue</a> page and write a description of your problem. Include as much information as you can, ideally also include relevant excerpts from your Home Manager configuration.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-contrib-getting-started"></a>5.1. Getting started</h2></div></div></div><p>If you have not previously forked Home Manager then you need to do that first. Have a look at GitHubs <a class="link" href="https://help.github.com/articles/fork-a-repo/" target="_top">Fork a repo</a> for instructions on how to do this.</p><p>Once you have a fork of Home Manager you should create a branch starting at the most recent <code class="literal">master</code> branch. Give your branch a reasonably descriptive name. Commit your changes to this branch and when you are happy with the result and it fulfills <a class="xref" href="index.html#sec-guidelines" title="5.2. Guidelines">Section 5.2, “Guidelines”</a> then push the branch to GitHub and <a class="link" href="https://help.github.com/articles/creating-a-pull-request/" target="_top">create a pull request</a>.</p><p>Assuming your clone is at <code class="literal">$HOME/devel/home-manager</code> then you can make the <code class="literal">home-manager</code> command use it by either</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">
overriding the default path by using the <code class="literal">-I</code> command line option:
</p><pre class="programlisting console">$ home-manager -I home-manager=$HOME/devel/home-manager</pre><p class="simpara">or</p></li><li class="listitem"><p class="simpara">
changing the default path by ensuring your configuration includes
</p><pre class="programlisting nix">programs.home-manager.enable = true;
programs.home-manager.path = "$HOME/devel/home-manager";</pre><p class="simpara">and running <code class="literal">home-manager switch</code> to activate the change. Afterwards, <code class="literal">home-manager build</code> and <code class="literal">home-manager switch</code> will use your cloned repository.</p></li></ol></div><p>The first option is good if you only temporarily want to use your clone.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-guidelines"></a>5.2. Guidelines</h2></div></div></div><p>If your contribution satisfy the following rules then there is a good chance it will be merged without too much trouble. The rules are enforced by the Home Manager maintainers and to a lesser extent the Home Manager CI system.</p><p>If you are uncertain how these rules affect the change you would like to make then feel free to start a discussion in the <a class="link" href="https://webchat.oftc.net/?channels=home-manager" target="_top">#home-manager</a> IRC channel, ideally before you start developing.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-back-compat"></a>5.2.1. Maintain backward compatibility</h3></div></div></div><p>Your contribution should not cause another users existing configuration to break unless there is a very good reason and the change should be announced to the user through an <a class="link" href="https://nixos.org/manual/nixos/stable/index.html#sec-assertions" target="_top">assertion</a> or similar.</p><p>Remember that Home Manager is used in many different environments and you should consider how your change may effect others. For example,</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Does your change work for people that do not use NixOS? Consider other GNU/Linux distributions and macOS.
</li><li class="listitem">
Does your change work for people whose configuration is built on one system and deployed on another system?
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-forward-compat"></a>5.2.2. Keep forward compatibility in mind</h3></div></div></div><p>The master branch of Home Manager tracks the unstable channel of Nixpkgs, which may update package versions at any time. It is therefore important to consider how a package update may affect your code and try to reduce the risk of breakage.</p><p>The most effective way to reduce this risk is to follow the advice in <a class="xref" href="index.html#sec-guidelines-valuable-options" title="5.2.3. Add only valuable options">Section 5.2.3, “Add only valuable options”</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-valuable-options"></a>5.2.3. Add only valuable options</h3></div></div></div><p>When creating a new module it is tempting to include every option supported by the software. This is <span class="emphasis"><em>strongly</em></span> discouraged. Providing many options increases maintenance burden and risk of breakage considerably. This is why only the most <a class="link" href="https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md#valuable-options" target="_top">important software options</a> should be modeled explicitly. Less important options should be expressible through an <code class="literal">extraConfig</code> escape hatch.</p><p>A good rule of thumb for the first implementation of a module is to only add explicit options for those settings that absolutely must be set for the software to function correctly. It follows that a module for software that provides sensible default values for all settings would require no explicit options at all.</p><p>If the software uses a structured configuration format like a JSON, YAML, INI, TOML, or even a plain list of key/value pairs then consider using a <code class="literal">settings</code> option as described in <a class="link" href="https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md" target="_top">Nix RFC 42</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-add-tests"></a>5.2.4. Add relevant tests</h3></div></div></div><p>If at all possible, make sure to add new tests and expand existing tests so that your change will keep working in the future. See <a class="xref" href="index.html#sec-tests" title="5.6. Tests">Section 5.6, “Tests”</a> for more information about the Home Manager test suite.</p><p>All contributed code <span class="emphasis"><em>must</em></span> pass the test suite.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-module-maintainer"></a>5.2.5. Add relevant documentation</h3></div></div></div><p>Many code changes require changing the documentation as well. Module options should be documented with DocBook. See <a class="link" href="https://berbiche.github.io/docbook.rocks/" target="_top">DocBook rocks!</a> for a quick introduction and <a class="link" href="https://tdg.docbook.org/" target="_top">DocBook 5: The Definitive Guide</a> for in-depth information of DocBook. Home Manager is itself documented using a combination of DocBook and <a class="link" href="https://asciidoc.org/" target="_top">AsciiDoc</a>. All text is hosted in Home Managers Git repository.</p><p>The HTML version of the manual containing both the module option descriptions and the documentation of Home Manager can be generated and opened by typing the following in a shell within a clone of the Home Manager Git repository:</p><pre class="programlisting console">$ nix-build -A docs.html
$ xdg-open ./result/share/doc/home-manager/index.html</pre><p>When you have made changes to a module, it is a good idea to check that the man page version of the module options looks good:</p><pre class="programlisting console">$ nix-build -A docs.manPages
$ man ./result/share/man/man5/home-configuration.nix.5</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_add_yourself_as_a_module_maintainer"></a>5.2.6. Add yourself as a module maintainer</h3></div></div></div><p>Every new module <span class="emphasis"><em>must</em></span> include a named maintainer using the <code class="literal">meta.maintainers</code> attribute. If you are a user of a module that currently lacks a maintainer then please consider adopting it.</p><p>If you are present in the NixOS maintainer list then you can use that entry. If you are not then you can add yourself to <code class="literal">modules/lib/maintainers.nix</code> in the Home Manager project.</p><p>Also add yourself to <code class="literal">.github/CODEOWNERS</code> as owner of the associated module files, including the test files. You will then be automatically added as a reviewer on any new pull request that touches your files.</p><p>Maintainers are encouraged to join the IRC channel and participate when they have opportunity.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-code-style"></a>5.2.7. Format your code</h3></div></div></div><p>Make sure your code is formatted as described in <a class="xref" href="index.html#sec-code-style" title="5.4. Code Style">Section 5.4, “Code Style”</a>. To maintain consistency throughout the project you are encouraged to browse through existing code and adopt its style also in new code.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-commit-message-style"></a>5.2.8. Format your commit messages</h3></div></div></div><p>Similar to <a class="xref" href="index.html#sec-guidelines-code-style" title="5.2.7. Format your code">Section 5.2.7, “Format your code”</a> we encourage a consistent commit message format as described in <a class="xref" href="index.html#sec-commit-style" title="5.3. Commits">Section 5.3, “Commits”</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-news-style"></a>5.2.9. Format your news entries</h3></div></div></div><p>If your contribution includes a change that should be communicated to users of Home Manager then you can add a news entry. The entry must be formatted as described in <a class="xref" href="index.html#sec-news" title="5.5. News">Section 5.5, “News”</a>.</p><p>When new modules are added a news entry should be included but you do not need to create this entry manually. The merging maintainer will create the entry for you. This is to reduce the risk of merge conflicts.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-conditional-modules"></a>5.2.10. Use conditional modules and news</h3></div></div></div><p>Home Manager includes a number of modules that are only usable on some of the supported platforms. The most common example of platform specific modules are those that define systemd user services, which only works on Linux systems.</p><p>If you add a module that is platform specific then make sure to include a condition in the <code class="literal">loadModule</code> function call. This will make the module accessible only on systems where the condition evaluates to <code class="literal">true</code>.</p><p>Similarly, if you are adding a news entry then it should be shown only to users that may find it relevant, see <a class="xref" href="index.html#sec-news" title="5.5. News">Section 5.5, “News”</a> for a description of conditional news.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-guidelines-licensing"></a>5.2.11. Mind the license</h3></div></div></div><p>The Home Manager project is covered by the MIT license and we can only accept contributions that fall under this license, or are licensed in a compatible way. When you contribute self written code and documentation it is assumed that you are doing so under the MIT license.</p><p>A potentia
{long description}</pre><p>where <code class="literal">{component}</code> refers to the code component (or module) your change affects, <code class="literal">{description}</code> is a very brief description of your change, and <code class="literal">{long description}</code> is an optional clarifying description. As a rare exception, if there is no clear component, or your change affects many components, then the <code class="literal">{component}</code> part is optional. See <a class="xref" href="index.html#ex-commit-message" title="Example 5.1. Compliant commit message">Example 5.1, “Compliant commit message”</a> for a commit message that fulfills these requirements.</p><div class="example"><a id="ex-commit-message"></a><p class="title"><strong>Example 5.1. Compliant commit message</strong></p><div class="example-contents"><p>The commit <a class="link" href="https://github.com/nix-community/home-manager/commit/69f8e47e9e74c8d3d060ca22e18246b7f7d988ef" target="_top">69f8e47e9e74c8d3d060ca22e18246b7f7d988ef</a> contains the commit message</p><pre class="screen">starship: allow running in Emacs if vterm is used
The vterm buffer is backed by libvterm and can handle Starship prompts
without issues.</pre><p>which ticks all the boxes necessary to be accepted in Home Manager.</p></div></div><br class="example-break" /><p>Finally, when adding a new module, say <code class="literal">programs/foo.nix</code>, we use the fixed commit format <code class="literal">foo: add module</code>. You can, of course, still include a long description if you wish.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-code-style"></a>5.4. Code Style</h2></div></div></div><p>The code in Home Manager is formatted by the <a class="link" href="https://github.com/serokell/nixfmt/" target="_top">nixfmt</a> tool and the formatting is checked in the pull request tests. Run the <code class="literal">format</code> tool inside the project repository before submitting your pull request.</p><p>Keep lines at a reasonable width, ideally 80 characters or less. This also applies to string literals.</p><p>We prefer <code class="literal">lowerCamelCase</code> for variable and attribute names with the accepted exception of variables directly referencing packages in Nixpkgs which use a hyphenated style. For example, the Home Manager option <code class="literal">services.gpg-agent.enableSshSupport</code> references the <code class="literal">gpg-agent</code> package in Nixpkgs.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-news"></a>5.5. News</h2></div></div></div><p>Home Manager includes a system for presenting news to the user. When making a change you, therefore, have the option to also include an associated news entry. In general, a news entry should only be added for truly noteworthy news. For example, a bug fix or new option does generally not need a news entry.</p><p>If you do have a change worthy of a news entry then please add one in <a class="link" href="https://github.com/nix-community/home-manager/blob/master/modules/misc/news.nix" target="_top"><code class="literal">news.nix</code></a> but you should follow some basic guidelines:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">
The entry timestamp should be in ISO-8601 format having "+00:00" as time zone. For example, "2017-09-13T17:10:14+00:00". A suitable timestamp can be produced by the command
</p><pre class="programlisting console">$ date --iso-8601=second --universal</pre></li><li class="listitem">
The entry condition should be as specific as possible. For example, if you are changing or deprecating a specific option then you could restrict the news to those users who actually use this option.
</li><li class="listitem">
Wrap the news message so that it will fit in the typical terminal, that is, at most 80 characters wide. Ideally a bit less.
</li><li class="listitem">
Unlike commit messages, news will be read without any connection to the Home Manager source code. It is therefore important to make the message understandable in isolation and to those who do not have knowledge of the Home Manager internals. To this end it should be written in more descriptive, prose like way.
</li><li class="listitem"><p class="simpara">
If you refer to an option then write its full attribute path. That is, instead of writing
</p><pre class="screen">The option 'foo' has been deprecated, please use 'bar' instead.</pre><p class="simpara">it should read</p><pre class="screen">The option 'services.myservice.foo' has been deprecated, please
use 'services.myservice.bar' instead.</pre></li><li class="listitem"><p class="simpara">
A new module, say <code class="literal">foo.nix</code>, should always include a news entry that has a message along the lines of
</p><pre class="screen">A new module is available: 'services.foo'.</pre><p class="simpara">If the module is platform specific, e.g., a service module using systemd, then a condition like</p><pre class="programlisting nix">condition = hostPlatform.isLinux;</pre><p class="simpara">should be added. If you contribute a module then you dont need to add this entry, the merger will create an entry for you.</p></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-tests"></a>5.6. Tests</h2></div></div></div><p>Home Manager includes a basic test suite and it is highly recommended to include at least one test when adding a module. Tests are typically in the form of "golden tests" where, for example, a generated configuration file is compared to a known correct file.</p><p>It is relatively easy to create tests by modeling the existing tests, found in the <code class="literal">tests</code> project directory.</p><p>The full Home Manager test suite can be run by executing</p><pre class="programlisting console">$ nix-shell --pure tests -A run.all</pre><p>in the project root. List all test cases through</p><pre class="programlisting console">$ nix-shell --pure tests -A list</pre><p>and run an individual test, for example <code class="literal">alacritty-empty-settings</code>, through</p><pre class="programlisting console">$ nix-shell --pure tests -A run.alacritty-empty-settings</pre></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="ch-faq"></a>Chapter 6. Frequently Asked Questions (FAQ)</h1></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_why_is_there_a_collision_error_when_switching_generation"></a>6.1. Why is there a collision error when switching generation?</h2></div></div></div><p>Home Manager currently installs packages into the user environment, precisely as if the packages were installed through <code class="literal">nix-env --install</code>. This means that you will get a collision error if your Home Manager configuration attempts to install a package that you already have installed manually, that is, packages that shows up when you run <code class="literal">nix-env --query</code>.</p><p>For example, imagine you have the <code class="literal">hello</code> package installed in your environment</p><pre class="programlisting console">$ nix-env --query
hello-2.10</pre><p>and your Home Manager configuration contains</p><pre class="programlisting nix">home.packages = [ pkgs.hello ];</pre><p>Then attempting to switch to this configuration will result in an error similar to</p><pre class="programlisting console">$ home-manager switch
these derivations will be built:
/nix/store/xg69wsnd1rp8xgs9qfsjal017nf0ldhm-home-manager-path.drv
[…]
Activating installPackages
replacing old home-manager-path
installing home-manager-path
building path(s) /nix/store/b5c0asjz9f06l52l9812w6k39ifr49jj-user-environment
Wide character in die at /nix/store/64jc9gd2rkbgdb4yjx3nrgc91bpjj5ky-buildenv.pl line 79.
collision between /nix/store/fmwa4axzghz11cnln5absh31nbhs9lq1-home-manager-path/bin/hello and /nix/store/c2wyl8b9p4afivpcz8jplc9kis8rj36d-hello-2.10/bin/hello; use nix-env --set-flag priority NUMBER PKGNAME to change the priority of one of the conflicting packages
builder for /nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv failed with exit code 2
error: build of /nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv failed</pre><p>The solution is typically to uninstall the package from the environment using <code class="literal">nix-env --uninstall</code> and reattempt the Home Manager generation switch.</p><p>You could also opt to unistall <span class="emphasis"><em>all</em></span> of the packages from your profile with <code class="literal">nix-env --uninstall '*'</code>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_why_are_the_session_variables_not_set"></a>6.2. Why are the session variables not set?</h2></div></div></div><p>Home Manager is only able to set session variables automatically if it manages your Bash, Z shell, or fish shell configuration. To enable such management you use <a class="xref" href="options.html#opt-programs.bash.enable"><code class="option">programs.bash.enable</code></a>, <a class="xref" href="options.html#opt-programs.zsh.enable"><code class="option">programs.zsh.enable</code></a>, or <a class="xref" href="options.html#opt-programs.fish.enable"><code class="option">programs.fish.enable</code></a>.</p><p>If you dont want to let Home Manager manage your shell then you will have to manually source the <code class="literal">~/.nix-profile/etc/profile.d/hm-session-vars.sh</code> file in an appropriate way. In Bash and Z shell this can be done by adding</p><pre class="programlisting bash">. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"</pre><p>to your <code class="literal">.profile</code> and <code class="literal">.zshrc</code> files, respectively. The <code class="literal">hm-session-vars.sh</code> file should work in most Bourne-like shells. For fish shell, it is possible to source it using <a class="link" href="https://github.com/oh-my-fish/plugin-foreign-env" target="_top">the foreign-env plugin</a></p><pre class="programlisting bash">fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" &gt; /dev/null</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_how_to_set_up_a_configuration_for_multiple_users_machines"></a>6.3. How to set up a configuration for multiple users/machines?</h2></div></div></div><p>A typical way to prepare a repository of configurations for multiple logins and machines is to prepare one "top-level" file for each unique combination.</p><p>For example, if you have two machines, called "kronos" and "rhea" on which you want to configure your user "jane" then you could create the files</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<code class="literal">kronos-jane.nix</code>,
</li><li class="listitem">
<code class="literal">rhea-jane.nix</code>, and
</li><li class="listitem">
<code class="literal">common.nix</code>
</li></ul></div><p>in your repository. On the kronos and rhea machines you can then make <code class="literal">~jane/.config/nixpkgs/home.nix</code> be a symbolic link to the corresponding file in your configuration repository.</p><p>The <code class="literal">kronos-jane.nix</code> and <code class="literal">rhea-jane.nix</code> files follow the format</p><pre class="programlisting nix">{ ... }:
{
imports = [ ./common.nix ];
# Various options that are specific for this machine/user.
}</pre><p>while the <code class="literal">common.nix</code> file contains configuration shared across the two logins. Of course, instead of just a single <code class="literal">common.nix</code> file you can have multiple ones, even one per program or service.</p><p>You can get some inspiration from the <a class="link" href="https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/" target="_top">Post your home-manager home.nix file!</a> Reddit thread.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal"></a>6.4. Why do I get an error message about <code class="literal">ca.desrt.dconf</code> or <code class="literal">dconf.service</code>?</h2></div></div></div><p>You are most likely trying to configure something that uses dconf
but the DBus session is not aware of the dconf service.
The full error you might get is</p><pre class="screen">error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files</pre><p>or</p><pre class="screen">error: GDBus.Error:org.freedesktop.systemd1.NoSuchUnit: Unit dconf.service not found.</pre><p>The solution on NixOS is to add</p><pre class="programlisting nix">programs.dconf.enable = true;</pre><p>to your system configuration.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_how_do_i_install_packages_from_nixpkgs_unstable"></a>6.5. How do I install packages from Nixpkgs unstable?</h2></div></div></div><p>If you are using a stable version of Nixpkgs but would like to install some particular packages from Nixpkgs unstable or some other channel then you can import the unstable Nixpkgs and refer to its packages within your configuration. Something like</p><pre class="programlisting nix">{ pkgs, config, ... }:
let
pkgsUnstable = import &lt;nixpkgs-unstable&gt; {};
in
{
home.packages = [
pkgsUnstable.foo
];
# …
}</pre><p>should work provided you have a Nix channel called <code class="literal">nixpkgs-unstable</code>.</p><p>You can add the <code class="literal">nixpkgs-unstable</code> channel by running</p><pre class="programlisting console"># nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
# nix-channel --update</pre><p>Note, the package will not be affected by any package overrides, overlays, etc.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_how_do_i_override_the_package_used_by_a_module"></a>6.6. How do I override the package used by a module?</h2></div></div></div><p>By default Home Manager will install the package provided by your chosen <code class="literal">nixpkgs</code> channel but occasionally you might end up needing to change this package. This can typically be done in two ways.</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">
If the module provides a <code class="literal">package</code> option, such as <code class="literal">programs.beets.package</code>, then this is the recommended way to perform the override. For example,
</p><pre class="programlisting nix">programs.beets.package = pkgs.beets.override { enableCheck = true; };</pre></li><li class="listitem"><p class="simpara">
If no <code class="literal">package</code> option is available then you can typically override the relevant package using an <a class="link" href="https://nixos.org/nixpkgs/manual/#chap-overlays" target="_top">overlay</a>.
</p><p class="simpara">For example, if you want to use the <code class="literal">programs.skim</code> module but use the <code class="literal">skim</code> package from Nixpkgs unstable, then a configuration like</p><pre class="programlisting nix">{ pkgs, config, ... }:
let
pkgsUnstable = import &lt;nixpkgs-unstable&gt; {};
in
{
programs.skim.enable = true;
nixpkgs.overlays = [
(self: super: {
skim = pkgsUnstable.skim;
})
];
# …
}</pre><p class="simpara">should work OK.</p></li></ol></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="options.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"> </td><td width="40%" align="right" valign="top"> Appendix A. Configuration Options</td></tr></table></div></body></html>