How to find the cause of a dependency

I am leaning to use flakes. But the problem I am facing is more general.

I need to set the priority of clang to high because otherwise tools from gcc-wrapper collide with clangs tools. So I am wondering how to find out what causes a package to be linked into a development environment.

{
  description = "pw-viz flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
    nci.url = "github:yusdacra/nix-cargo-integration";
    nci.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, nci, ... }:
    nci.lib.makeOutputs {
      root = ./.;
      overrides = {
        shell = common: prev: {
          packages = prev.packages ++ [
            common.pkgs.xorg.libX11
            common.pkgs.xorg.libXcursor
            common.pkgs.xorg.libXrandr
            common.pkgs.xorg.libXi
            common.pkgs.xorg.libxcb
            common.pkgs.libGL
            (common.pkgs.hiPrio common.pkgs.clang)
          ];
        };
        crateOverrides = common: prev: {
          "libspa-sys" = prev: {
            buildInputs = (prev.buildInputs or [ ]) ++ [
              common.pkgs.pipewire
              common.pkgs.libclang
            ];
            nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ [
              common.pkgs.pkgconfig
            ];
          };
        };
      };
    };
}

UPDATE: the answer is basically here:
https://nixos.org/guides/nix-pills/automatic-runtime-dependencies.html#automatic-runtime-dependencies
and
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-why-depends.html

1 Like

Nice! I’m learning to use NixOS. By curiosity, I always thought that collisions does not really matter in NixOS. Did you have some issues? :slight_smile: Or it’s simply to have a clean build?

Collisions need to be resolved when you write your own flake/package. For example both gcc and clang provide cc and ld binaries, so you need to define which one should be used.

Thank you for the answer :slight_smile: