Can I specify an unstable package using home-manager

I am using stable NixOS and have configured qutebrowser using home-manager. This obviously pulls in the most current package from stable. Is there a way to specify the unstable version of qutebrowser using home-manager?

certainly! the FAQ entry for using packages from unstable doesn’t just apply to nixos, it can be used pretty much anywhere a package is used.

I don’t understand how to apply this to the home-manager module.

I tried this but it didn’t work:

programs.qutebrowser.package = pkgs.unstable.qutebrowser;

This gave:

error: attribute 'unstable' missing

I am using flake.nix that looks like this (in part):

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-22.11"; # stable

Do I need to add something to allow access to unstable?

there is no pkgs.unstable. you have to declare and use the unstable channel as its entirely own thing, then use that to get your new package.

on flakes it’s a little more complicated, there you can declare a new input unstable.url = "nixpkgs/nixos-unstable" to get a new unstable argument to your outputs function, then use unstable.legacyPackages.<yourSystemType>.qutebrowser to get the package.

OK. I gave this a try, and I think I got the flake.nix configured correctly. After updating, I got confirmation that a new input called “unstable” was added.

However, when I tried specifying the unstable version of qutebrowser in my home-manager configuration like this:

  programs.qutebrowser = {
    enable = true;
    package = unstable.legacyPackages.x86_64-linux.qutebrowser;

I get the following:

error: undefined variable 'unstable'

       at /nix/store/pwwdg1wsqhp222g2h3n5p0rg58i6j8xp-source/users/user/home.nix:654:15:

          653|     enable = true;
          654|     package = unstable.legacyPackages.x86_64-linux.qutebrowser;
             |               ^

You need to include unstable as an input on your flake:

{
  inputs = {
    nixpkgs-unstable.url = <put here the url>;
    . . . # other inputs
  };

  outputs = { self, nixpkgs-unstable, /* other inputs*/, . . .}: 
}

Yes, I mentioned above that I think I got my flake configured properly. When I ran nix flake update, I got a message back tha a new input unstable was added.

I also have unstable listed as one of my outputs.

Do I need to modify anything in the homeConfigurations section of my flake?

Maybe you need to configure an overlay. The function home-manager.lib.homeManagerConfiguration receives an argument pkgs, usually pointing to Nixpkgs, but it can be modified to include an overlay.
The overlay would include the unstable packages you want to override or add.

Indeed I use a similar trick to include my dotfiles collection:

You could look here for one option: https://github.com/Misterio77/nix-starter-configs/tree/main/standard

Thanks everyone for your help. It is just too opaque for me. I think I have just too much of a deficit in my understanding of NixOS to make sense of any of this. I thought this might be an easy thing to do.

Please take a look at my blog post which describes how to get your inputs into the configurations.

The examples are for using a non-legacy package set with nixosSystem, though all of the techniques als work for HM nearly the same way. And when there are notable differences I have mentioned them.

You also want to use legacyPackages rather than packages as its used in the examples, due to how nixpkgs-flake is organized.

https://blog.nobbz.dev/posts/2022-12-12-getting-inputs-to-modules-in-a-flake/

1 Like

Thanks @NobbZ . I appreciate the help.

I had the flake config correct. I was struggling with how to specify the unstable package in home-manager.
Here is what ended up working:

package = inputs.nixpkgs-unstable.legacyPackages.x86_64-linux.qutebrowser;

I was missing the “inputs.” part before “nixpkgs-unstable”.
I hate not fully understanding everything.

2 Likes

Don’t be sad. Nixpkgs has some hard-to-understand corners.