Extra-builtins linker errors

I’m having this problem: "could not dynamically open plugin file" on non-NixOS · Issue #24 · shlevy/nix-plugins · GitHub

They’re using the version of nix that comes with 25.05 it appears. I’ve created a flake that is using nixpkgs-unstable. Unfortunately that version uses nix 2.32 and it would appear that nix-plugins is still on 2.30 so it is again incompatible no matter whether I’m correctly following nixpkgs or not.

I’ve tried to find a commit that would be on nix 2.30 so nix-plugins might be compatible but I can’t find one.

The person who asked there received an answer but I don’t know how to apply it and I’ve tried various different ways. I’d like to apply this in a flake that I’d like to work without having to patch the system–I want to share this flake and have it work for people so they don’t run into the same stuff I’ve been.

So I’m just trying to make a devshell that has a working extra-builtins that’s got a hello in it per instruction here: Evaluation time secrets in Nix: Importing encrypted nix files | oddlama's blog

As is I cannot configure my nix system to do this at all because if I do the nix command becomes broken because nix-plugins does not work. So it doesn’t matter if I do in flake or not.

How would I apply the override suggested and build nix-plugins for the version in nixpkgs so it works in the devshell in this flake? I’ve been at this a very long time before asking for help. Maybe there’s a way to just find what I want to know but either my search skills are garbage or AI has made it impossible. Only directions I can find are for applying it to a nixos install and I’m not trying to do that.

{
  description = "Description for the project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    devshell = {
      url = "github:numtide/devshell";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    flake-parts = {
      url = "github:hercules-ci/flake-parts";
    };
  };

  outputs = inputs@{ flake-parts, devshell, nixpkgs, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        devshell.flakeModule
      ];
      systems = [ "x86_64-linux" "aarch64-linux" ];
      perSystem = { config, self', inputs', pkgs, system, ... }: {
        devshells.default = 
          { extraModulesPath, ... }:
          {
            packages = [
              pkgs.nix
            ];

            env = [
              {
                name = "NIX_CONFIG";
                value = ''
                  plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins
                  extra-builtins-file = ${./.}/flake/extra-builtins.nix
                '';
              }
            ];
          };
      };
      flake = {

      };
    };
}

No, it works with nix 2.32.
Show us what you tried and what the error is.

I activate the development environment in the flake I pasted and then try to run nix --version. I get this:

error: could not dynamically open plugin file '"/nix/store/0qzr3y1z3qq7jvsx59xhl0w3h7cdyh1i-nix-plugins-16.0.1/lib/nix/plugins/libnix-extra-builtins.so"': /nix/store/0qzr3y1z3qq7jvsx59xhl0w3h7cdyh1i-nix-plugins-16.0.1/lib/nix/plugins/libnix-extra-builtins.so: undefined symbol: _ZN3nix6Config11getSettingsERSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_14AbstractConfig11SettingInfoESt4lessIS7_ESaISt4pairIKS7_S9_EEEb

The blog I liked to also has steps to try to do this in your active shell:

$ nix build --no-link --print-out-paths nixpkgs#nix-plugins
/nix/store/0q842xsb1yddrn8jxi2dm6njry1cxjmd-nix-plugins-14.0.0

$ export NIX_CONFIG="
plugins-files=/nix/store/0q842xsb1yddrn8jxi2dm6njry1cxjmd-nix-plugins-14.0.0/lib/nix/plugins
extra-builtins-file=/absolute/path/to/extra-builtins.nix
"

I run the first command and get the store path that matches the one in the error. Then if I do the NIX_CONFIG step with that path instead I get that same error without using the flake.

I’m trying to do that right now but keep getting a syntax error when I adjust the store name and I’m giving up. I can’t even find how to fix that issue because if I search for netting the config through environment variables all I get is a bunch of stuff about how to set environment variables, generally…which I can in fact do. There’s a syntax error in this somewhere:


estrange@leviathan:~/development/strange-crew/nix-first$ export NIX_CONFIG="
> plugins-file=/nix/store/0qzr3y1z3qq7jvsx59xhl0w3h7cdyh1i-nix-plugins-16.0.1/lib/nix/plugins
> "
estrange@leviathan:~/development/strange-crew/nix-first$ nix --version
error: syntax error in configuration line 'plugins-file=/nix/store/0qzr3y1z3qq7jvsx59xhl0w3h7cdyh1i-nix-plugins-16.0.1/lib/nix/plugins' in 'NIX_CONFIG'
Try 'nix --help' for more information.
estrange@leviathan:~/development/strange-crew/nix-first$ nix --help
error: syntax error in configuration line 'plugin-files=[/nix/store/0qzr3y1z3qq7jvsx59xhl0w3h7cdyh1i-nix-plugins-16.0.1/lib/nix/plugins]' in 'NIX_CONFIG'
Try 'nix --help' for more information.

I went and uninstalled nix to try and install 2.30 anyway. It didn’t fix the problem because my flake installs its own version, which it’s supposed to, and that is 2.32 no matter what I do unless I go back to far and get 2.28 – and I can’t figure out now how to set the damn config without getting that error from it. It works in the flake, but not if I do it in the shell like that. The flake causes a linker error instead.

This is on a nix install on a ubuntu based system (mint).

I realize that plugin-files isn’t spelled right in my example. First of all, if that’s the issue it shouldn’t be a “syntax error”, but whatever. The other thing though is that I’ve tried many variations on that word, including the one in the manual (that has no examples of configuring this value successfully so…) and get the same “syntax error” report.

Here’s some evidence that you are in error.

So I did install 2.30 like I said to try to solve this issue. I can’t seem to figure out how to set it in the command line environment without getting a syntax error, but if I tell the flake to stop following nixpkgs and to not install pkgs.nix in the devshell then I can use nix in that environment:

[devshell]$ nix --version
nix (Nix) 2.30.0

It did not, however, load my builtin so I don’t know…maybe it just silently failed to do any of what I said instead? The env variable is set:

devshell]$ echo $NIX_CONFIG
plugin-files = /nix/store/0qzr3y1z3qq7jvsx59xhl0w3h7cdyh1i-nix-plugins-16.0.1/lib/nix/plugins extra-builtins-file = /nix/store/98i4z9w9677kby2pjlhm8fjiy0yxsiqa-pz84zswng9k1df1pgd2c30bc03rx8bg7-source/flake/extra-builtins.nix
[devshell]$ 

My extra-builtins.nix is this:

_:
{
  helloWorld = "Hello!";
}

I solved this problem. My extra-builtins.nix wasn’t known to git so didn’t make it to the store.

So the setup works if I don’t follow the directions to follow nixpkgs. According to the blog this is going to blow up in my face eventually.

This is really strong evidence that at least when you don’t have nix installed as the OS then nix 2.32 is not compatible with the nix-plugins that comes with it. I had to downgrade my system and tell the flake to stop upgrading in order to make this work.

So it would be nice if I knew how to do this overlay thing so I can build nix-plugins as part of my flake so I know it’s going to work on matter what. Where I need to go to learn how to do that?

Here’s my latest mangled attempt:

{
  description = "Description for the project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    devshell = {
      url = "github:numtide/devshell";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    flake-parts = {
      url = "github:hercules-ci/flake-parts";
    };

    nix-plugins = {
      url = "github:shlevy/nix-plugins";
    };
  };

  outputs = inputs@{ flake-parts, devshell, nixpkgs, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        devshell.flakeModule
      ];
      systems = [ "x86_64-linux" "aarch64-linux" ];
      perSystem = { config, self', inputs', system, ... }: 
      let
        pkgs = import inputs.nixpkgs {
          inherit system;
          overlays = [

            (final: prev: {
              nix-plugins = inputs.nix-plugins.override {
                nixComponents = inputs.nixpkgs.nixVersions.nixComponents_2_30;
              };
            })
          ];
        };
      in
      {
        devshells.default = 
          { extraModulesPath, ... }:
          {
            packages = [
              #pkgs.nix
            ];

            env = [
              {
                name = "NIX_CONFIG";
                value = ''
                  plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins
                  extra-builtins-file = ${./.}/flake/extra-builtins.nix
                '';
              }
            ];
          };
      };
      flake = {

      };
    };
}

I’m trying to piece together:

So I’m seriously just lost. Don’t even know how to start.

No, it works.
https://github.com/shlevy/nix-plugins/pull/23
https://github.com/NixOS/nixpkgs/pull/455579

Make sure you’re using nixos-unstable.

Sigh.

I am.

Forget it then. I’m giving up. This approach at least. Maybe nix entirely.

In your last flake the line inputs.nix-plugins.override should (as the PR is in current nixos-unstable Nixpkgs-tracker and overriding a flake like this won’t work) be replaced by pkgs.nix-plugins.override or you use the pkgs.nix-plugins.overrideAttrs with buildInputs pattern from this gh issue Deployment on host with nix-plugins · Issue #10 · oddlama/nix-config · GitHub
Also the import can simply be pkgs = inputs.nixpkgs.legacyPackages.${system} as you don’t need an overlay for that one override. And please use that pkgs defined then in all places inputs.nixpkgs is used.
Your flake should become less intimidating by that immediately.

Following minimal example works on an Archlinux:

flake.nix
{
  description = "Description for the project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs =
    inputs@{ ... }:
    let
      pkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
    in
    {
      devShell."x86_64-linux" = pkgs.mkShell {
        packages = [
	  pkgs.nixVersions.latest # use latest nix version, should match the version used as buildInputs below
        ];
        shellHook = ''
          export NIX_CONFIG="
  	    plugin-files = ${
                 pkgs.nix-plugins.overrideAttrs (o: {
                   buildInputs = [
                     pkgs.nixVersions.latest
                   ];
                 })
               }/lib/nix/plugins
	    extra-builtins-file = ${./.}/extra-builtins.nix
          "
        '';
      };
    };
}
extra-builtins.nix
_args: {
  helloWorld = "Hello World!";
}
flake.lock
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1762596750,
        "narHash": "sha256-rXXuz51Bq7DHBlfIjN7jO8Bu3du5TV+3DSADBX7/9YQ=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "b6a8526db03f735b89dd5ff348f53f752e7ddc8e",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

nix develop

bash-5.3$ nix repl
Nix 2.32.3
Type :? for help.
nix-repl> builtins.extraBuiltins.helloWorld
"Hello World!"
  • system: "x86_64-linux"
  • host os: Linux 6.14.4-arch1-2, Arch Linux, noversion, rolling
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.32.3
  • channels(root): ""
  • nixpkgs: /nix/store/aiqa5bkggpp47cjg6p17j8l9w3bmabz7-source
2 Likes