Skip to content

Commit

Permalink
vcpkg: make builtin-baseline work
Browse files Browse the repository at this point in the history
Consider this vcpkg.json file:

  {
    "dependencies": [ "fmt", "zlib" ],
    "builtin-baseline": "101ae1f63a22d262f80a68034a1550da5dfdd05f"
  }

Before this change, if you tried to run “vcpkg install” with that
vcpkg.json file, then vcpkg would fail with this error:

  error: while checking out baseline from commit '101ae1f63a22d262f80a68034a1550da5dfdd05f', failed to `git show` versions/baseline.json. This may be fixed by fetching commits with `git fetch`.
  error: git failed with exit code: (128).
  fatal: not a git repository: '.git'
  while checking out baseline 101ae1f63a22d262f80a68034a1550da5dfdd05f

This commit fixes that problem.
  • Loading branch information
Jayman2000 committed Jul 21, 2024
1 parent c114399 commit 79e11b3
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkgs/by-name/vc/vcpkg/package.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ fetchFromGitHub
, stdenvNoCC
, lib
, git
, vcpkg-tool
, makeWrapper
, doWrap ? true
Expand All @@ -14,7 +15,11 @@ stdenvNoCC.mkDerivation (finalAttrs: {
owner = "microsoft";
repo = "vcpkg";
rev = finalAttrs.version;
hash = "sha256-eDpMGDtC44eh0elLWV0r1H/WbpVdZ5qMedKh7Ct50Cs=";
hash = "sha256-omHlViym0hs02cn/25nUVtNVa38yowByttZ2vjqpWhs=";
# If you use a builtin-baseline in a vcpkg.json file, then vcpkg will try
# to run “git show <baseline-commit>”. We need a deep clone in order to
# ensure that that works.
deepClone = true;
};

nativeBuildInputs = [ makeWrapper ];
Expand All @@ -32,12 +37,21 @@ stdenvNoCC.mkDerivation (finalAttrs: {
installPhase = ''
runHook preInstall
mkdir -p "$out/bin" "$out/share/vcpkg/scripts/buildsystems"
cp --preserve=mode -r ./{docs,ports,triplets,scripts,.vcpkg-root,versions,LICENSE.txt} "$out/share/vcpkg/"
mkdir -p "$out/bin" "$out/libexec/vcpkg" "$out/share/vcpkg/scripts/buildsystems"
cp --preserve=mode -r ./{.git,docs,ports,triplets,scripts,.vcpkg-root,versions,LICENSE.txt} "$out/share/vcpkg/"
${lib.optionalString doWrap ''
# If you use a builtin-baseline in a vcpkg.json file, then vcpkg will
# try to run “git show” on $out/share/vcpkg. By default, Git will fail
# if a Git repo isn’t owned by the current user. We create a wrapper
# for git here to make sure that the “git show” command succeeds, even
# if the user running vcpkg doesn’t own $out/share/vcpkg.
makeWrapper "${git}/bin/git" "$out/libexec/vcpkg/git" \
--add-flags -c --add-flags safe.directory="$out/share/vcpkg"
makeWrapper "${vcpkg-tool}/bin/vcpkg" "$out/bin/vcpkg" \
--set-default VCPKG_ROOT "$out/share/vcpkg"
--set-default VCPKG_ROOT "$out/share/vcpkg" \
--prefix PATH : "$out/libexec/git"
''}
ln -s "$out/bin/vcpkg" "$out/share/vcpkg/vcpkg"
Expand Down

0 comments on commit 79e11b3

Please sign in to comment.