How to return a set from package.nix?

Hi everyone.

I created this PR which introduces a font with several variants. The PR defines by-name/ap/aporetic/package.nix which returns an attribute set and not a derivation (e.g., it provides aporetic.sans-mono and aporetic.serif, not just aporetic). The PR fails building because of that:

pkgs.aporetic: This attribute defined by pkgs/by-name/ap/aporetic/package.nix is not a derivation

Any idea what I should do?

https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name#recommendation-for-new-packages-with-multiple-versions

Or use one package, multiple outputs.

1 Like

Thank you @waffle8946 (nice nickname, I’m hungry now). I tried the first solution of the link like this:

  {
    inherit ({
      "sans-mono" = makeIosevkaFont "sans-mono";
      "sans" = makeIosevkaFont "sans";
      "serif-mono" = makeIosevkaFont "serif-mono";
      "serif" = makeIosevkaFont "serif";
    }) "sans-mono" "sans" "serif-mono" "serif";
  }

but I got the same error message. I then read the manual about multiple outputs. While a split derivation seems possible, the manual reminded me of symlinkJoin which I used successfully. The advantage is that there is now only one derivation to use for people which makes things simpler. The problem is that it is not possible to install only “sans-mono” but I can live with that for now.

Thank you for your help.