NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.07k stars 14.06k forks source link

srt pkg-config include path incorrect #70872

Closed j0sh closed 5 years ago

j0sh commented 5 years ago

Describe the bug After installing the srt module, the include path as shown by pkg-config is incorrect. The path is prefixed twice., eg /path/to/srt//path/to/srt/include

To Reproduce Steps to reproduce the behavior:

  1. Make this nix-shell derivation:
with import <nixpkgs> {};

stdenv.mkDerivation rec {
  name = "env";
  env = buildEnv { name = "env"; paths = buildInputs;  };
  buildInputs = [
    pkg-config
    srt
  ];
}
  1. Run pkg-config --cflags srt
$ pkg-config --cflags srt
-I/nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2//nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2/include -I/nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2//nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2/include/srt

Note that the prefix is included twice.

Inspecting the .pc file confirms this:

$ cat /nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2/lib/pkgconfig/srt.pc 
prefix=/nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}//nix/store/a2yngvr7i16pik628clnkzhvc77x5mx7-srt-1.3.2/include

Expected behavior

The include path should be correct. In particular, the includedir shouldn't be doubled up.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Metadata Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.

$ nix run nixpkgs.nix-info -c nix-info -m
[2 copied (0.0 MiB), 0.0 MiB DL]
 - system: `"x86_64-darwin"`
 - host os: `Darwin 18.7.0, macOS 10.14.6`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.2.2`
 - channels(josh): `"nixpkgs-19.09pre186574.88d9f776091"`
 - nixpkgs: `/Users/josh/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: srt
j0sh commented 5 years ago

cc @nh2 (the maintainer?) since this issue probably slipped in under the radar

nh2 commented 5 years ago

Uh, ugly. Thanks for pinging me.

This is not srt specific, but seems like a common cmake problem, see e.g.:

https://github.com/NixOS/nixpkgs/blob/1230fc8674439df5a90fe4c1ea740256ef9906e4/pkgs/development/compilers/hhvm/default.nix#L41-L44

% git grep CMAKE_INSTALL_INCLUDEDIR
pkgs/applications/science/misc/root/5.nix:    "-DCMAKE_INSTALL_INCLUDEDIR=include"
pkgs/applications/science/misc/root/default.nix:    "-DCMAKE_INSTALL_INCLUDEDIR=include"
pkgs/applications/science/robotics/gazebo/default.nix:  "-DCMAKE_INSTALL_INCLUDEDIR=include" ]
pkgs/desktops/lxqt/libqtxdg/default.nix:      "-DCMAKE_INSTALL_INCLUDEDIR=include"
pkgs/development/compilers/hhvm/default.nix:  # the cmake package does not handle absolute CMAKE_INSTALL_INCLUDEDIR correctly
pkgs/development/compilers/hhvm/default.nix:  cmakeFlags = "-DCMAKE_INSTALL_INCLUDEDIR=include";
pkgs/development/compilers/solc/patches/shared-libs-install.patch:+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libdevcore
pkgs/development/compilers/solc/patches/shared-libs-install.patch:+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libevmasm
pkgs/development/compilers/solc/patches/shared-libs-install.patch:+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libsolidity
pkgs/development/compilers/solc/patches/shared-libs-install.patch:+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libyul
pkgs/development/compilers/solc/patches/shared-libs-install.patch:+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/liblangutil
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:-    "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:-    "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:-    "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:-    "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/gtest/fix-cmake-config-includedir.patch:+    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
pkgs/development/libraries/hyperscan/default.nix:      --replace "includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@" "includedir=@CMAKE_INSTALL_INCLUDEDIR@"
pkgs/development/libraries/ignition-math/default.nix:    cmakeFlags="$cmakeFlags -DCMAKE_INSTALL_INCLUDEDIR=include -DCMAKE_INSTALL_LIBDIR=lib"
pkgs/development/libraries/srt/default.nix:    # the cmake package does not handle absolute CMAKE_INSTALL_INCLUDEDIR correctly
pkgs/development/libraries/srt/default.nix:    "-DCMAKE_INSTALL_INCLUDEDIR=include"
pkgs/development/libraries/yder/fix-pkgconfig.patch:-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
pkgs/development/libraries/yder/fix-pkgconfig.patch:+includedir=@CMAKE_INSTALL_INCLUDEDIR@
pkgs/development/tools/build-managers/cmake/setup-hook.sh:    cmakeFlags="-DCMAKE_INSTALL_INCLUDEDIR=${!outputInclude}/include $cmakeFlags"

On the srt side, it worked fine before upstream change https://github.com/Haivision/srt/pull/421/files because it was hardcoded before.

nh2 commented 5 years ago

PR with fix for master in #71669; should be backported to 19.09 afterwards.

nh2 commented 3 years ago

@dtzWill I noticed you picked and then reverted it ^

Is there a better way to do this?

I still get this problem with many other packages.