How do you generate a dependency tree for a broken package?

nix-tree and various nix-store -q commands seem to work but only for packages that you were successfully able to build. nix why-depends doesn’t seem to work for packages that are marked broken on your platform. Here’s an example:

> NIXPKGS_ALLOW_BROKEN=1 nix why-depends --all nixpkgs#mkvtoolnix nixpkgs#compiler-rt
error: Package ‘compiler-rt-5.0.2’ in /nix/store/ra71v2rndffy7h06kgvaid0ccck0fjhg-source/pkgs/development/compilers/llvm/5/compiler-rt/default.nix:92 is marked as broken, refusing to evaluate.

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

            $ export NIXPKGS_ALLOW_BROKEN=1

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowBroken = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowBroken = true; }
       to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)

I tried adding allowBroken = true; into my /etc/nix/nix.conf as well as to .config/nixpkgs/config.nix as this command suggests, but they didn’t seem to have any effect.


A separate question: how do you override dependencies? I tried the following in an overlay but they don’t seem to have any effect:

  llvmPackage_5.compiler-rt = pkgs.llvmPackages_13.compiler-rt;
  llvmPackage_5 = pkgs.llvmPackages_13;

I’m really curious about this aswell. Currently I have a broken Python package, I’ve commented out all Python packages but something depends on this still, no idea what it is and no idea how to find out.

I’ve tried with nix-tree and it doesn’t show the package at all.

I ended up just building like this:

NIXPKGS_ALLOW_BROKEN=1 nixos-rebuild build --keep-failed --use-remote-sudo --flake /home/lillecarl/Code/nixos --impure

Then i used nix-tree on the system derivation that failed and could search out the package.

This doesn’t feel like the beaten path, but it worked. For me it was opensnitch-ui that broke my build, not using opensnitch so I removed it and am now happy again! :slight_smile:

1 Like