How to find which package dependency it is?

Hello there,

I’m trying to update my flake based installation of NixOS. When doing the nixos-rebuild switch I get this error:

       error: Package ‘electron-27.3.11’ in /nix/store/l6spwdi1xs20q24fqfi3xwxx0d2x9q2m-source/pkgs/development/tools/electron/binary/generic.nix:36 is marked as insecure, refusing to evaluate.


       Known issues:
        - Electron version 27.3.11 is EOL

       You can install it anyway by allowing this package, using the
       following methods:

       a) To temporarily allow all insecure packages, you can use an environment
          variable for a single invocation of the nix tools:

            $ export NIXPKGS_ALLOW_INSECURE=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) for `nixos-rebuild` you can add ‘electron-27.3.11’ to
          `nixpkgs.config.permittedInsecurePackages` in the configuration.nix,
          like so:

            {
              nixpkgs.config.permittedInsecurePackages = [
                "electron-27.3.11"
              ];
            }

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
          ‘electron-27.3.11’ to `permittedInsecurePackages` in
          ~/.config/nixpkgs/config.nix, like so:

            {
              permittedInsecurePackages = [
                "electron-27.3.11"
              ];

Now, I don’t know which one of my packages needs this. So I wanted to know, how can I track back this dependency ?

Thanks !

I know of nix-store for querying the nix store. For example:

nix-store --query --referrers /nix/store/s5yfqhxzlcpw0ps2vb3gizicvharnd2n-xz-5.6.2

nix-store --query --references /nix/store/s5yfqhxzlcpw0ps2vb3gizicvharnd2n-xz-5.6.2

nix-store --query --help

I guess that relies on the package existing in the store. Perhaps you can install it temporarily (as suggested when nixos-rebuild fails) then do a nixos-rebuild test instead of switch?

When you rebuild, use --show-trace and scroll through the logs (I know…) to get info on the package it was trying to build. You will see some message like while evaluating derivation <packagename>.

Some filtering along these lines could be done, e.g.

nixos-rebuild build --show-trace 2>/dev/stdout | grep 'while evaluating derivation'

(Normally I’d suggest nix-tree --derivation or such, but I doubt it’d work here as this is an eval-time error.)

There aren’t many packages that depend on electron_27 in nixpkgs anyway, a simple ripgrep gives the following:

  • logseq
  • micropad
  • pocket-casts
  • whalebird

Well, found the culprit, Logseq.

Thanks for your help !