Nix-env -i runs out of memory with unstable overlay

I’m running NixOS, and I would like to use the unstable channel for a single package (zathura in this case). The way I figure I could do this add the unstable channel with nix-channel (as normal user), and add the following overlay:

self: super:
let
  unstable = import <unstable> {};
in {
  zathura = unstable.zathura;
}

Then, I would nix-env -i zathura.

However, this command runs out of memory (all 16GB of it) and fails.

On the other hand, when I remove the overlay, something like nix run -f '<unstable>' zathura works exactly like expected, and certainly doesn’t run out of memory.

What am I doing wrong? What is the recommended way of installing a single package from the unstable channel?

Thanks in advance for the help!

It looks like the overlay also gets applied when importing unstable, resulting in infinite recursion. Not sure if thats true or why that is the case.

Note that in this case (since zathura is an end-user application) you don’t really need an overlay. Simply doing

{ config, pkgs, ... }:
let
  unstable = import  <unstable> {};
in
{
  environment.systemPackages = with pkgs; [
    ...
  ] ++ with unstable; [
    zathura
  ]
  ...
}

should be enough.

Hey, that worked! I just needed some brackets like this:

{ config, pkgs, ... }:
let
  unstable = import  <unstable> {};
in
{
  environment.systemPackages = with pkgs; [
    ...
  ] ++ (with unstable; [
    zathura
  ]);
  ...
}

Apart from that, this works great, thank for the help!

After much fiddling I discovered how to break the “import cycle” by overridings the overlays attribute. Here’s an overlay that will add an unstable sub-package to your nixpkgs:

self: super:

{
  unstable = import <unstable> { overlays = []; };
}
2 Likes