How to overlay packages from package sets? (haskellPackages.crypton)

I am getting a strange error when applying any overlay to haskellPackages.crypton. It seems to happen to literally any overlay implemented via the nixpkgs.overlays option. Example of a very simple overlay below with the error message:

    nixpkgs.overlays = [
      (self: super: {
        haskellPackages.crypton = super.haskellPackages.crypton.override (oldAttrs: {
          mesonFlags = oldAttrs.mesonFlags;
        });
      })
    ];
error:
       … while calling the 'head' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1:35741:
       … while evaluating the attribute 'value'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:34707:
       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `warnings':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix':

       … while evaluating the option `systemd.services.libvirtd-config.serviceConfig':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix':

       … while evaluating the option `systemd.services.libvirtd-config.script':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/virtualisation/libvirtd.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'pandoc-cli' missing
       at /nix/store/lnz81i2lfvk77az9hzgxdxg198b9yc56-nixos/nixos/pkgs/by-name/pa/pandoc/package.nix:8:25:
            7|   installShellFiles,
            8|   selectPandocCLI ? (p: p.pandoc-cli), # The version of pandoc-cli choosen from haskellPackages.
             |                         ^
            9| }:

I suspect the issue is with how I am dealing with a package set VS pkgs.package as I have overlaid before, but I haven’t been able to find anything on how to overlay packages from package sets.

I also tried:

    nixpkgs.overlays = [
      (self: super: {
        haskellPackages = super.haskellPackages // {
          crypton = super.haskellPackages.crypton.overrideAttrs (oldAttrs: {
            # attribute here
          });
        };
      })

based on another post in discourse.nixos but no matter what attribute I tried it wouldn’t affect the derivation.

With you’re first attempt you’re replacing the entire haskellPackages set with one that contains a single package. The second attempt makes sense, but I don’t think it works due to implementation details. The correct way should be something like this:

self: super: {
  haskellPackages = super.haskellPackages.override {
    overrides = hself: hsuper: { 
       crypton = self.haskell.lib.compose.overrideCabal hsuper.crypton (oldAttrs: {
        ...
       });
    };
  };
}

alternatively:

self: super: {
  haskellPackages = super.haskellPackages.extend (hself: hsuper: {
     crypton = self.haskell.lib.compose.overrideCabal hsuper.crypton (oldAttrs: {
      ...
     });
  };
}
1 Like

Thanks!

I tried both – here is the copy-paste from my configuration:

First

    nixpkgs.overlays = [
      (self: super: {
        haskellPackages = super.haskellPackages.override {
          overrides = hself: hsuper: { 
            crypton = self.haskell.lib.compose.overrideCabal hsuper.crypton (oldAttrs: {
              name = "testIgnore";
            });
          };
        };  
      })
    ];

Alternative
(you forgot a round bracket)

    nixpkgs.overlays = [
      (self: super: {
        haskellPackages = super.haskellPackages.extend (hself: hsuper: {
          crypton = self.haskell.lib.compose.overrideCabal hsuper.crypton (oldAttrs: {
            name = "testIgnore";
          });
        });
      })
    ];

Both produced the error:

error:
       … while calling the 'head' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1:35741:
       … while evaluating the attribute 'value'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:34707:
       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `warnings':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix':

       … while evaluating the option `systemd.services.libvirtd-config.serviceConfig':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix':

       … while evaluating the option `systemd.services.libvirtd-config.script':

       … while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/virtualisation/libvirtd.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found a function: «lambda @ /etc/nixos/configuration.nix:707:76»

The problematic line is is crypton = self.haskell.lib.compose.overrideCabal hsuper.crypton (oldAttrs: {

Sorry, I got the arguments order wrong. Here’s the fix:

 nixpkgs.overlays = [
    (self: super: {
      haskellPackages = super.haskellPackages.extend (hself: hsuper: {
        crypton = self.haskell.lib.compose.overrideCabal (oldAttrs: {
          pname = "testIgnore";
        }) hsuper.crypton;
      });
    })
  ];

It worked! Thank you!