Append to zfs configureFlags

I’m trying to debug a zfs issue I’m having and have been asked by the zfs maintainers to do the equivalent of ./configure --enable-debug && make for the version of zfs I’m running on my system. I’m running NixOS 20.09 with zfs.enableUnstable = true;.

I poked around in the zfs packages and can see that I basically want to append --enable-debug`` to the configureFlags` list but I don’t know how to do that. To clarify, I’m wanting this change to take effect globally on my running system the next time I reboot.

Thanks for any pointers.

Sounds like you’re looking for a ZFS overlay, that updates the configureFlags attribute.

Something like:

self: super:
{
  linuxPackages.zfsUnstable = super.linuxPackages.zfsUnstable.overrideAttrs (
    old:
      {
        configureFlags = old.configureFlags ++ [ "--enable-debug" ];
      }
  );
}

( not tested )

This should combine the “–enable-debug” flag with the existing flags defined in the zfs package.

Thanks for the help, but I’m still having trouble putting it all together and making something work. When I try adding the above into my configuration.nix according to the fancy nix.overlays method shown in the wiki, I get an error about rtl8030bs not being defined properly. It smelled like maybe linuxPackages isn’t the right thing to be overriding, but I’ve tried various related things without success.

I got the following to at least do something without errors, but I only noticed compilation of the userspace tools fly by. Is there a way to verify what actually got built? (In parallel I’m asking the zfs folks how to tell from a running system if I have debug enabled).

  nixpkgs.config.packageOverrides = pkgs: {
    zfsUnstable = pkgs.zfsUnstable.overrideAttrs (
      old: {
        configureFlags = old.configureFlags ++ [ "--enable-debug" ];
      }
    );

    kernelPackages.zfsUnstable = pkgs.kernelPackages.zfsUnstable.overrideAttrs (
      old: {
        configureFlags = old.configureFlags ++ [ "--enable-debug" ];
      }
    );
  };

Thanks for any further help.

I dug deeper and found that the zfs kernel module prints a “debug” message when it loads if it has been compiled with debugging information. I’m not seeing it. I’ve worked my way through Nix Pills, scoured various forum posts and old notes that I have, and can’t come up with something that works. The closest I’ve gotten is something that lets nixos-rebuild boot work correctly, but when I boot, I’m still running the standard NixOS zfsUnstable without debugging.

Can anyone help me get over the line? Here’s the “latest and greatest”:

  nixpkgs.overlays = [
    (self: super: {
      linuxPackages_5_4 = super.linuxPackages_5_4 // {
        zfsUnstable = super.linuxPackages_5_4.zfsUnstable.overrideAttrs (
          old:
          {
            configureFlags = old.configureFlags ++ [ "--enable-debug" ];
          }
        );
      };
    })
  ];

  boot.kernelPackages = pkgs.linuxPackages_5_4;

Any help is greatly appreciated.

I’ve got something working. Here it is for anyone else trying to do something similar. It makes the zfsUnstable module use debugging with the default linuxPackages kernel. So boot.zfs.enableUnstable = true; must also be set.

 nixpkgs.overlays = [
    (self: super: {
      linuxPackages = super.linuxPackages.extend (lpself: lpsuper: {
        zfsUnstable = super.linuxPackages.zfsUnstable.overrideAttrs (oldAttrs: {
          configureFlags = oldAttrs.configureFlags ++ [ "--enable-debug" ];
        });
      });
    })
  ];

Thanks to @mattchrist for helping.

1 Like