Nixpkgs: How to install and use run-clang-tidy.py?

Created on 3 Jan 2018  Â·  3Comments  Â·  Source: NixOS/nixpkgs

Issue description

How can I install and use run-clang-tidy.py? I've installed clang (also tried clang-tools), and I see run-clang-tidy.py in my Nix store, but I have no idea how to correctly get it on my PATH. It looks like the clang derivation may use multiple outputs? I'm not sure how to install a particular output, though. The following fails

$ nix-env -i clang.python
error: selector ‘clang.python’ matches no derivations
$ nix-env -iA nixpkgs.clang.python
error: attribute ‘python’ in selection path ‘nixpkgs.clang.python’ not found
$ nix-env -iA nixpkgs.llvmPackages.clang-python
error: attribute ‘clang-python’ in selection path ‘nixpkgs.llvmPackages.clang-python’ not found

Is there any easy way to discover the correct attribute? Or, given the path to run-clang-tidy.py in the Nix store, is there a way to lookup its corresponding attribute?

Steps to reproduce

$ nix-env -i clang
$ find /nix -name run-clang-tidy.py
/nix/store/l52vx9bsw164cdllj3r1w4i21yyxyczj-clang-4.0.1-python/share/clang/run-clang-tidy.py
$ which run-clang-tidy.py
$ echo $?
1

Technical details

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-darwin"`
 - host os: `Darwin 16.7.0, macOS 10.12.6`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 1.11.16`
 - channels(root): `"nixpkgs-18.03pre122585.b212125b541"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

question python

Most helpful comment

It does not appear that putting llvmPackages_6.clang-unwrapped.python in the buildInputs of a nix-shell description is sufficient to get run-clang-tidy.py on the PATH.

nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.102, NixOS, 18.09.2266.aabc61049c0 (Jellyfish)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.1.3`
 - channels(siddharthist): `"unstable-19.03pre164964.b0f40b78513"`
 - channels(root): `"nixos-18.09.2266.aabc61049c0"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

All 3 comments

Outputs are simply attributes of the derivation. Note, however, that we wrap clang but the wrapped derivation does not have the python output. Therefore, we need clang-unwrapped. To build the output:

$ nix-build -A llvmPackages.clang-unwrapped.python

The attribute is given in the previous answer. There is no easy way to find these kind of attributes/outputs.

It does not appear that putting llvmPackages_6.clang-unwrapped.python in the buildInputs of a nix-shell description is sufficient to get run-clang-tidy.py on the PATH.

nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.102, NixOS, 18.09.2266.aabc61049c0 (Jellyfish)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.1.3`
 - channels(siddharthist): `"unstable-19.03pre164964.b0f40b78513"`
 - channels(root): `"nixos-18.09.2266.aabc61049c0"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Was this page helpful?
0 / 5 - 0 ratings