fork/home-manager
git clone https://git.julia.blue/fork/home-manager
cae54dc4
master
1[[ch-faq]] 2== Frequently Asked Questions (FAQ) 3 4=== Why is there a collision error when switching generation? 5 6Home Manager currently installs packages into the user environment, precisely as if the packages were installed through `nix-env --install`. 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 `nix-env --query`. 7 8For example, imagine you have the `hello` package installed in your environment 9 10[ source,console ] 11---- 12$ nix-env --query 13hello-2.10 14---- 15 16and your Home Manager configuration contains 17 18[ source,nix ] 19---- 20home.packages = [ pkgs.hello ]; 21---- 22 23Then attempting to switch to this configuration will result in an error similar to 24 25[ source,console ] 26---- 27$ home-manager switch 28these derivations will be built: 29/nix/store/xg69wsnd1rp8xgs9qfsjal017nf0ldhm-home-manager-path.drv 30[…] 31Activating installPackages 32replacing old ‘home-manager-path’ 33installing ‘home-manager-path’ 34building path(s) ‘/nix/store/b5c0asjz9f06l52l9812w6k39ifr49jj-user-environment’ 35Wide character in die at /nix/store/64jc9gd2rkbgdb4yjx3nrgc91bpjj5ky-buildenv.pl line 79. 36collision 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 37builder for ‘/nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv’ failed with exit code 2 38error: build of ‘/nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv’ failed 39---- 40 41The solution is typically to uninstall the package from the environment using `nix-env --uninstall` and reattempt the Home Manager generation switch. 42 43You could also opt to unistall _all_ of the packages from your profile with `nix-env --uninstall '*'`. 44 45=== Why are the session variables not set? 46: foreign-env : https://github.com/oh-my-fish/plugin-foreign-env 47 48Home 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 <<opt-programs.bash.enable>>, <<opt-programs.zsh.enable>>, or <<opt-programs.fish.enable>>. 49 50If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding 51 52[ source,bash ] 53---- 54. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" 55---- 56 57to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells. For fish shell, it is possible to source it using {foreign-env}[the foreign-env plugin] 58 59[ source,bash ] 60---- 61fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" > /dev/null 62---- 63 64=== How to set up a configuration for multiple users/machines? 65: post-your-homenix : https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/ 66 67A typical way to prepare a repository of configurations for multiple logins and machines is to prepare one "top-level" file for each unique combination. 68 69For 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 70 71- `kronos-jane.nix`, 72- `rhea-jane.nix`, and 73- `common.nix` 74 75in your repository. 76On the kronos and rhea machines you can then make 77`~jane/.config/home-manager/home.nix` 78be a symbolic link to the corresponding file in your configuration repository. 79 80The `kronos-jane.nix` and `rhea-jane.nix` files follow the format 81 82[ source,nix ] 83---- 84{ ... }: 85 86{ 87imports = [ ./common.nix ]; 88 89# Various options that are specific for this machine/user. 90} 91---- 92 93while the `common.nix` file contains configuration shared across the two logins. Of course, instead of just a single `common.nix` file you can have multiple ones, even one per program or service. 94 95You can get some inspiration from the {post-your-homenix}[Post your home-manager home.nix file!] Reddit thread. 96 97=== Why do I get an error message about `ca.desrt.dconf` or `dconf.service`? 98 99You are most likely trying to configure something that uses dconf 100but the DBus session is not aware of the dconf service. 101The full error you might get is 102 103---- 104error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files 105---- 106 107or 108 109---- 110error: GDBus.Error:org.freedesktop.systemd1.NoSuchUnit: Unit dconf.service not found. 111---- 112 113The solution on NixOS is to add 114 115[ source,nix ] 116programs.dconf.enable = true; 117 118to your system configuration. 119 120=== How do I install packages from Nixpkgs unstable? 121 122If 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 123 124[ source,nix ] 125---- 126{ pkgs, config, ... }: 127 128let 129 130pkgsUnstable = import <nixpkgs-unstable> {}; 131 132in 133 134{ 135home.packages = [ 136pkgsUnstable.foo 137]; 138 139# … 140} 141---- 142 143should work provided you have a Nix channel called `nixpkgs-unstable`. 144 145You can add the `nixpkgs-unstable` channel by running 146 147[ source,console ] 148---- 149$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable 150$ nix-channel --update 151---- 152 153Note, the package will not be affected by any package overrides, overlays, etc. 154 155=== How do I override the package used by a module? 156: nixpkgs-overlays : https://nixos.org/nixpkgs/manual/#chap-overlays 157 158By default Home Manager will install the package provided by your chosen `nixpkgs` channel but occasionally you might end up needing to change this package. This can typically be done in two ways. 159 1601. If the module provides a `package` option, such as `programs.beets.package`, then this is the recommended way to perform the override. For example, 161+ 162[ source,nix ] 163programs.beets.package = pkgs.beets.override { enableCheck = true; }; 164 1652. If no `package` option is available then you can typically override the relevant package using an {nixpkgs-overlays}[overlay]. 166+ 167For example, if you want to use the `programs.skim` module but use the `skim` package from Nixpkgs unstable, then a configuration like 168+ 169[ source,nix ] 170---- 171{ pkgs, config, ... }: 172 173let 174 175pkgsUnstable = import <nixpkgs-unstable> {}; 176 177in 178 179{ 180programs.skim.enable = true; 181 182nixpkgs.overlays = [ 183(self: super: { 184skim = pkgsUnstable.skim; 185}) 186]; 187 188# … 189} 190---- 191+ 192should work OK.