silx: 2.1.1 -> 2.1.2 (#361612)
[NixPkgs.git] / pkgs / by-name / vc / vcpkg / package.nix
blobf35b29fe33e38e60c5d557eef4ba88f836fa7761
1 { fetchFromGitHub
2 , stdenvNoCC
3 , lib
4 , vcpkg-tool
5 , makeWrapper
6 , doWrap ? true
7 }:
9 stdenvNoCC.mkDerivation (finalAttrs: {
10   pname = "vcpkg";
11   version = "2024.10.21";
13   src = fetchFromGitHub {
14     owner = "microsoft";
15     repo = "vcpkg";
16     rev = finalAttrs.version;
17     hash = "sha256-OBGaNK+gKIdes/7jgvsKshDT19Wv2N6vqUtTDchvu+o=";
18     leaveDotGit = true;
19     postFetch = ''
20       cd "$out"
21       VCPKG_BASELINE_COMMIT_SHA=$(git rev-parse --verify HEAD)
22       # We only needed the .git folder for that previous command, so we can safely delete it now.
23       # If we don’t delete it, then we might run into problems (see #8567).
24       rm -r .git
25       # Here's the code that Creates this json file in Visual Studio deployment and the code that reads it:
26       #   https://github.com/microsoft/vcpkg-tool/blob/f098d3e0aaa7e46ea84a1f7079586e1ec5af8ab5/vcpkg-init/mint-standalone-bundle.ps1#L21
27       #   https://github.com/microsoft/vcpkg-tool/blob/f098d3e0aaa7e46ea84a1f7079586e1ec5af8ab5/src/vcpkg/bundlesettings.cpp#L87
28       #
29       # Here's the code that we target with this setting. If we use embeddedsha combined with usegitregistry, vcpkg
30       # will checkout a remote instead of trying to do git operation in the vcpkg root
31       #   https://github.com/microsoft/vcpkg-tool/blob/d272c0d4f5175b26bd56c6109d4c4935b791a157/src/vcpkg/vcpkgpaths.cpp#L920
32       #   https://github.com/microsoft/vcpkg-tool/blob/d272c0d4f5175b26bd56c6109d4c4935b791a157/src/vcpkg/configuration.cpp#L718
33       echo '{ "readonly": true, "usegitregistry": true, "deployment": "Git", "embeddedsha": "'"$VCPKG_BASELINE_COMMIT_SHA"'" }' > vcpkg-bundle.json
34     '';
35   };
37   nativeBuildInputs = [ makeWrapper ];
39   postPatch = ''
40     substituteInPlace scripts/toolchains/linux.cmake \
41       --replace-fail "aarch64-linux-gnu-as"  "aarch64-unknown-linux-gnu-as" \
42       --replace-fail "aarch64-linux-gnu-gcc" "aarch64-unknown-linux-gnu-gcc" \
43       --replace-fail "aarch64-linux-gnu-g++" "aarch64-unknown-linux-gnu-g++" \
44       --replace-fail "arm-linux-gnueabihf-as"  "armv7l-unknown-linux-gnueabihf-as" \
45       --replace-fail "arm-linux-gnueabihf-gcc" "armv7l-unknown-linux-gnueabihf-gcc" \
46       --replace-fail "arm-linux-gnueabihf-g++" "armv7l-unknown-linux-gnueabihf-g++"
47     # If we don’t turn this off, then you won’t be able to run binaries that
48     # are installed by vcpkg.
49     find triplets -name '*linux*.cmake' -exec bash -c 'echo "set(X_VCPKG_RPATH_KEEP_SYSTEM_PATHS ON)" >> "$1"' -- {} \;
50   '';
52   installPhase = ''
53       runHook preInstall
55       mkdir -p "$out/bin" "$out/share/vcpkg/scripts/buildsystems"
56       cp --preserve=mode -r ./{docs,ports,triplets,scripts,.vcpkg-root,versions,LICENSE.txt,vcpkg-bundle.json} "$out/share/vcpkg/"
58       ${lib.optionalString doWrap ''
59         makeWrapper "${vcpkg-tool}/bin/vcpkg" "$out/bin/vcpkg" \
60           --set-default VCPKG_ROOT "$out/share/vcpkg"
61       ''}
63       ln -s "$out/bin/vcpkg" "$out/share/vcpkg/vcpkg"
64       touch "$out/share/vcpkg/vcpkg.disable-metrics"
66       runHook postInstall
67     '';
69   meta = {
70     description = "C++ Library Manager for Windows, Linux, and macOS";
71     mainProgram = "vcpkg";
72     homepage = "https://vcpkg.io/";
73     license = lib.licenses.mit;
74     maintainers = with lib.maintainers; [ guekka gracicot h7x4 ];
75     platforms = lib.platforms.all;
76   };