How to add buildInputs for openldap package?

I’m trying to create an overlay for the openldap package with the smbk5pwd module. While building that I get an error about a missing krb5.h file. It seems I need to add the heimdal package to the buildInputs but that’s where I’m getting stuck. I tried the code below but I’m getting an infinite recursion error.

             overlay-openldap = final: prev: {
                # nixpkgs:/pkgs/development/libraries/openldap
                openldap = prev.openldap.overrideAttrs (_: rec {
                    buildInputs = prev.openldap.buildInputs ++ [prev.heimdal];

                    extraContribModules = [
                      # https://git.openldap.org/openldap/openldap/-/tree/master/contrib/slapd-modules
                      "passwd/sha2"
                      "passwd/pbkdf2"
                      "passwd/totp"
                      "smbk5pwd"
                    ];
                });
              };

How to add the heimdal package to the buildInputs?

You need to use the previous arguments that overrideAttrs provides.

overlay-openldap = final: prev: {
                # nixpkgs:/pkgs/development/libraries/openldap
                openldap = prev.openldap.overrideAttrs (a: {
                    buildInputs = a.buildInputs ++ [final.heimdal];

                    extraContribModules = [
                      # https://git.openldap.org/openldap/openldap/-/tree/master/contrib/slapd-modules
                      "passwd/sha2"
                      "passwd/pbkdf2"
                      "passwd/totp"
                      "smbk5pwd"
                    ];
                });
              };

I also changed the heimdal input to use the final set (not required, but nice if you’re not overriding it yourself) and removed the unnecessary rec.

2 Likes

Thanks for the quick reply and the changes make sense. Unfortunately I still get error: infinite recursion encountered.

It seems that openldap is a parameter passed to the heimdal package so that’s where that error comes from. I also had a look and maybe the krb5 package fits my purposes as well but that also has openldap as a parameter. However the krb5 package only needs openldap when building with withLdap = true but still gives me the same error about infinite recursion. Any ideas how to fix this?