Unable to get nix-plugins to work

I am unable to get nix-plugins to work, but am not sure what I’m doing wrong (or if the problem is with nix-plugins).

I have an extra-builtins.nix file that looks like this:

{ exec, ... }: {
  hello = exec ["echo" "\"hello\""];
}

And I used the patch from error: could not dynamically open plugin file · Issue #20 · shlevy/nix-plugins · GitHub to build nix-plugins (otherwise I get the error mentioned on that issue).

But when I run nix repl --option plugin-files /nix/store/zwf1zjfkpcbxp1008gxqjpxr223w18ih-nix-plugins-15.0.0/lib/nix/plugins --option extra-builtins-file ./extra-builtins.nix

I find that builtins.extraBuiltins is null, and so builtins.extraBuiltins.hello fails with error: expected a set but found null: null

Using an absolute path to the extra builtins file makes no difference.

Am I doing something wrong, or is nix-plugins not working with the latest version of nix, even with the patch from the gh issue? I assume the former, but I can’t see what it could be. I found various dotfiles repositories using nix-plugins, but couldn’t find anything in any of those that made it work for me.

(My approach is based on Secure, Declarative Key Management with NixOps, Pass, and nix-plugins and Evaluation time secrets in Nix: Importing encrypted nix files | oddlama's blog , but at the moment I’m just trying to get the most basic thing working).

I just ran into this myself and it was because my extra-builtins.nix wasn’t known to git. Once I added it and did a rebuild it worked.

Figured this out by verifying that the file was in the extra-builtins-file config with nix config show.

Looked up the documentation on that config option and it says that if the file doesn’t exist at the path given then it’ll set to null. Checked the path it was trying to load (which was in my store) and in fact it wasn’t there. Had the idea maybe it wasn’t in git, it wasn’t…tried it out.

Thank you for the reply. That wasn’t the problem in my case, but there have been some fixes to nix-plugins since then.

I still can’t get it working on 25.05, but on unstable it works if I do this:

let
  nix-plugins = pkgs.nix-plugins.override {
    nixComponents = pkgs.nixVersions.nixComponents_2_31;
  };
in
{
  nix.settings = {
    plugin-files = "${nix-plugins}/lib/nix/plugins";
    extra-builtins-file = [ ./extra-builtins.nix ];
  };
}