2023-10-10 20:10:23 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2024-07-01 18:03:13 +00:00
|
|
|
, runtimeShell
|
2023-10-10 20:10:23 +00:00
|
|
|
, cacert
|
|
|
|
, cmake
|
|
|
|
, cmakerc
|
2024-07-01 18:11:46 +00:00
|
|
|
, curl
|
2023-10-10 20:10:23 +00:00
|
|
|
, fmt
|
|
|
|
, git
|
|
|
|
, gzip
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, openssh
|
|
|
|
, python3
|
2024-07-01 18:11:46 +00:00
|
|
|
, unzip
|
2023-10-10 20:10:23 +00:00
|
|
|
, zip
|
|
|
|
, zstd
|
|
|
|
, extraRuntimeDeps ? []
|
2024-07-01 18:03:13 +00:00
|
|
|
, doWrap ? true
|
2023-10-10 20:10:23 +00:00
|
|
|
}:
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "vcpkg-tool";
|
2024-06-13 03:02:28 +00:00
|
|
|
version = "2024-06-10";
|
2023-10-10 20:10:23 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "microsoft";
|
|
|
|
repo = "vcpkg-tool";
|
|
|
|
rev = finalAttrs.version;
|
2024-06-13 03:02:28 +00:00
|
|
|
hash = "sha256-TGRTzUd1FtErD+h/ksUsUm1Rhank9/yVy06JbAgEEw0=";
|
2023-10-10 20:10:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
ninja
|
|
|
|
];
|
|
|
|
|
2024-06-20 15:00:16 +00:00
|
|
|
buildInputs = [
|
|
|
|
cmakerc
|
|
|
|
fmt
|
|
|
|
];
|
|
|
|
|
2023-10-10 20:10:23 +00:00
|
|
|
patches = [
|
|
|
|
./change-lock-location.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DVCPKG_DEPENDENCY_EXTERNAL_FMT=ON"
|
|
|
|
"-DVCPKG_DEPENDENCY_CMAKERC=ON"
|
|
|
|
];
|
|
|
|
|
2024-07-01 17:51:39 +00:00
|
|
|
|
|
|
|
passAsFile = [ "vcpkgWrapper" ];
|
|
|
|
vcpkgWrapper = let
|
2023-10-10 20:10:23 +00:00
|
|
|
# These are the most common binaries used by vcpkg
|
2024-07-01 18:03:13 +00:00
|
|
|
# Extra binaries can be added through override when needed
|
2023-10-10 20:10:23 +00:00
|
|
|
runtimeDeps = [
|
|
|
|
cacert
|
|
|
|
cmake
|
2024-07-01 18:11:46 +00:00
|
|
|
curl
|
2023-10-10 20:10:23 +00:00
|
|
|
git
|
|
|
|
gzip
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
openssh
|
|
|
|
python3
|
2024-07-01 18:11:46 +00:00
|
|
|
unzip
|
2023-10-10 20:10:23 +00:00
|
|
|
zip
|
|
|
|
zstd
|
|
|
|
] ++ extraRuntimeDeps;
|
2024-07-01 18:03:13 +00:00
|
|
|
|
|
|
|
# Apart from adding the runtime dependencies to $PATH,
|
|
|
|
# the wrapper will also override these arguments by default.
|
|
|
|
# This is to ensure that the executable does not try to
|
|
|
|
# write to the nix store. If the user tries to set any of the
|
|
|
|
# arguments themself, the wrapper will detect that the
|
|
|
|
# arguments are present, and prefer the user-provided value.
|
|
|
|
#
|
|
|
|
# It is also possible to override the cli arguments by
|
|
|
|
# settings either of the nix-specific environment variables.
|
|
|
|
argsWithDefault = [
|
|
|
|
{
|
|
|
|
arg = "--downloads-root";
|
|
|
|
env = "NIX_VCPKG_DOWNLOADS_ROOT";
|
|
|
|
default = "$NIX_VCPKG_WRITABLE_PATH/downloads";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
arg = "--x-buildtrees-root";
|
|
|
|
env = "NIX_VCPKG_BUILDTREES_ROOT";
|
|
|
|
default = "$NIX_VCPKG_WRITABLE_PATH/buildtrees";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
arg = "--x-packages-root";
|
|
|
|
env = "NIX_VCPKG_PACKAGES_ROOT";
|
|
|
|
default = "$NIX_VCPKG_WRITABLE_PATH/packages";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
arg = "--x-install-root";
|
|
|
|
env = "NIX_VCPKG_INSTALL_ROOT";
|
|
|
|
default = "$NIX_VCPKG_WRITABLE_PATH/installed";
|
|
|
|
}
|
|
|
|
];
|
2023-10-10 20:10:23 +00:00
|
|
|
in ''
|
2024-07-01 18:03:13 +00:00
|
|
|
#!${runtimeShell}
|
|
|
|
|
|
|
|
NIX_VCPKG_WRITABLE_PATH=''${NIX_VCPKG_WRITABLE_PATH:-''${XDG_CACHE_HOME+"$XDG_CACHE_HOME/vcpkg"}}
|
|
|
|
NIX_VCPKG_WRITABLE_PATH=''${NIX_VCPKG_WRITABLE_PATH:-''${HOME+"$HOME/.vcpkg/root"}}
|
|
|
|
NIX_VCPKG_WRITABLE_PATH=''${NIX_VCPKG_WRITABLE_PATH:-''${TMP}}
|
|
|
|
NIX_VCPKG_WRITABLE_PATH=''${NIX_VCPKG_WRITABLE_PATH:-'/tmp'}
|
|
|
|
|
|
|
|
${lib.concatMapStringsSep "\n" ({ env, default, ... }: ''${env}=''${${env}-"${default}"}'') argsWithDefault}
|
2024-07-01 17:51:39 +00:00
|
|
|
|
|
|
|
export PATH="${lib.makeBinPath runtimeDeps}''${PATH:+":$PATH"}"
|
|
|
|
|
2024-07-01 18:03:13 +00:00
|
|
|
ARGS=( "$@" )
|
|
|
|
FINAL_NONMODIFIED_ARGS=()
|
|
|
|
|
|
|
|
for (( i=0; i<''${#ARGS[@]}; i++ ));
|
|
|
|
do
|
|
|
|
case "''${ARGS[i]%%=*}" in
|
|
|
|
${let
|
|
|
|
f = { arg, env, ... }: ''
|
|
|
|
'${arg}')
|
|
|
|
${env}="''${ARGS[i]#*=}"
|
|
|
|
if [ "''$${env}" = '${arg}' ]; then
|
|
|
|
${env}="''${ARGS[i+1]}"
|
|
|
|
((i++))
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
'';
|
|
|
|
in lib.concatMapStringsSep "\n" f argsWithDefault}
|
|
|
|
*)
|
|
|
|
FINAL_NONMODIFIED_ARGS+=(''${ARGS[i]})
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
exec -a "$0" "${placeholder "out"}/bin/.vcpkg-wrapped" \
|
|
|
|
${lib.concatMapStringsSep "\n" ({ arg, env, ... }: " " + ''${arg}="''$${env}" \'') argsWithDefault}
|
|
|
|
"''${FINAL_NONMODIFIED_ARGS[@]}"
|
2024-07-01 17:51:39 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-01 18:03:13 +00:00
|
|
|
postFixup = lib.optionalString doWrap ''
|
2024-07-01 17:51:39 +00:00
|
|
|
mv "$out/bin/vcpkg" "$out/bin/.vcpkg-wrapped"
|
|
|
|
install -Dm555 "$vcpkgWrapperPath" "$out/bin/vcpkg"
|
2023-10-10 20:10:23 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Components of microsoft/vcpkg's binary";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "vcpkg";
|
2023-10-10 20:10:23 +00:00
|
|
|
homepage = "https://github.com/microsoft/vcpkg-tool";
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
maintainers = with lib.maintainers; [ guekka gracicot ];
|
|
|
|
platforms = lib.platforms.all;
|
|
|
|
};
|
|
|
|
})
|