Libnix_doc_plugin.so is putting me in an upgrade deadlock

when running:
nixos-rebuild switch --upgrade --keep-going --show-trace --verbose
got:

$ nix-instantiate --find-file nixpkgs --keep-going --show-trace --verbose
error: could not dynamically open plugin file '/nix/store/n9w4b77d14ynx36bxs86006z6ih5vmfj-nix-doc-0.5.8/lib/libnix_doc_plugin.so': /nix/store/n9w4b77d14ynx36bxs86006z6ih5vmfj-nix-doc-0.5.8/lib/libnix_doc_plugin
.so: undefined symbol: _ZN3nix14RegisterPrimOpC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPFvRNS_9EvalStateENS_6PosIdxEPPNS_5ValueERSA_E
building the system configuration...
Building in legacy (non-flake) mode.
No --build-host given, running nix-build locally
$ nix-build <nixpkgs/nixos> --no-out-link -A system --keep-going --show-trace --verbose
error: could not dynamically open plugin file '/nix/store/n9w4b77d14ynx36bxs86006z6ih5vmfj-nix-doc-0.5.8/lib/libnix_doc_plugin.so': /nix/store/n9w4b77d14ynx36bxs86006z6ih5vmfj-nix-doc-0.5.8/lib/libnix_doc_plugin
.so: undefined symbol: _ZN3nix14RegisterPrimOpC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPFvRNS_9EvalStateENS_6PosIdxEPPNS_5ValueERSA_E

I’m on unstable channel, but this issue seem smth to do with nixdoc plugin, and I have no clue how to stop it in nix.conf on the damn readonly fs.
any solution or idea?
(also if there is more info needed, inform me)

this is last line of nix.conf:
plugin-files = /nix/store/n9w4b77d14ynx36bxs86006z6ih5vmfj-nix-doc-0.5.8/lib/libnix_doc_plugin.so

I opened this file in chroot, and it seemed different, I guess its a part of nixos starting stages magic to change this file.

Override with nix-instantiate --plugin-files "" ...

I think I’m being abit too noob in here, but it shows

error: getting status of '/home/aarmn/default.nix': No such file or directory

what should I pass to it exactly?

This is this bug: error: could not dynamically open plugin file … libnix_doc_plugin.so · Issue #237637 · NixOS/nixpkgs · GitHub

The solution is to make a new nix config manually without plugin-files, remove plugin-files temporarily from your NixOS config, then rerun the rebuild.

This behaviour has been permanently fixed in a new version of nix-doc released a few weeks ago: we changed the linker flags to only resolve symbols when they’re actually used, and then added a nix version match check before continuing to load. So on the plus side it shouldn’t happen again. At the same time Nix should be more tolerant of this.

The cause here I think is that Nix usage in activation scripts results in some very silly behaviour: config builds properly with new Nix, then activates with old Nix and then oops plugins are broken. The exact details of cause don’t matter too much but basically plugins that don’t guard against version mismatch don’t work with NixOS.

@jade do you know if there’s an issue about this?

(the offending line is at
https://github.com/NixOS/nixpkgs/blob/863598fdfca2d0609fc1578cff0c3ec27fd13d9b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh#L608)

i guess the issue above but i closed it because it’s never going to happen again to nix-doc specifically. worth opening a new bug i think.