2022-10-18 12:39:31 +00:00
|
|
|
{ buildGoModule
|
|
|
|
, fetchFromGitHub
|
2022-10-18 15:06:05 +00:00
|
|
|
, python3Packages
|
2022-10-18 12:39:31 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
mkBasePackage =
|
|
|
|
{ pname
|
|
|
|
, src
|
|
|
|
, version
|
|
|
|
, vendorHash
|
|
|
|
, cmd
|
|
|
|
, extraLdflags
|
2023-09-25 21:10:13 +00:00
|
|
|
, env
|
2022-10-18 12:39:31 +00:00
|
|
|
, ...
|
|
|
|
}@args: buildGoModule (rec {
|
2023-09-25 21:10:13 +00:00
|
|
|
inherit pname src vendorHash version env;
|
2022-10-18 12:39:31 +00:00
|
|
|
|
|
|
|
sourceRoot = "${src.name}/provider";
|
|
|
|
|
|
|
|
subPackages = [ "cmd/${cmd}" ];
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
] ++ extraLdflags;
|
|
|
|
} // args);
|
2022-10-18 15:06:05 +00:00
|
|
|
|
|
|
|
mkPythonPackage =
|
|
|
|
{ meta
|
|
|
|
, pname
|
|
|
|
, src
|
|
|
|
, version
|
|
|
|
, ...
|
|
|
|
}: python3Packages.callPackage
|
2023-09-21 14:24:51 +00:00
|
|
|
({ buildPythonPackage, pythonOlder, parver, pip, pulumi, semver, setuptools }:
|
2022-10-18 15:06:05 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
inherit pname meta src version;
|
2023-09-21 14:24:51 +00:00
|
|
|
format = "pyproject";
|
2022-10-18 15:06:05 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
|
|
|
sourceRoot = "${src.name}/sdk/python";
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
parver
|
|
|
|
pulumi
|
|
|
|
semver
|
2023-09-21 14:24:51 +00:00
|
|
|
setuptools
|
2022-10-18 15:06:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2023-09-21 14:24:51 +00:00
|
|
|
if [[ -e "pyproject.toml" ]]; then
|
|
|
|
sed -i \
|
|
|
|
-e 's/^ version = .*/ version = "${version}"/g' \
|
|
|
|
pyproject.toml
|
|
|
|
else
|
|
|
|
sed -i \
|
|
|
|
-e 's/^VERSION = .*/VERSION = "${version}"/g' \
|
|
|
|
-e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "${version}"/g' \
|
|
|
|
setup.py
|
|
|
|
fi
|
2022-10-18 15:06:05 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Auto-generated; upstream does not have any tests.
|
|
|
|
# Verify that the version substitution works
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
2023-09-21 14:24:51 +00:00
|
|
|
${pip}/bin/pip show "${pname}" | grep "Version: ${version}" > /dev/null \
|
2022-10-18 15:06:05 +00:00
|
|
|
|| (echo "ERROR: Version substitution seems to be broken"; exit 1)
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
(builtins.replaceStrings [ "-" ] [ "_" ] pname)
|
|
|
|
];
|
|
|
|
})
|
|
|
|
{ };
|
2022-10-18 12:39:31 +00:00
|
|
|
in
|
|
|
|
{ owner
|
|
|
|
, repo
|
|
|
|
, rev
|
|
|
|
, version
|
|
|
|
, hash
|
|
|
|
, vendorHash
|
|
|
|
, cmdGen
|
|
|
|
, cmdRes
|
|
|
|
, extraLdflags
|
2023-09-25 21:10:13 +00:00
|
|
|
, env ? { }
|
2022-10-18 12:39:31 +00:00
|
|
|
, meta
|
|
|
|
, fetchSubmodules ? false
|
|
|
|
, ...
|
|
|
|
}@args:
|
|
|
|
let
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
name = "source-${repo}-${rev}";
|
|
|
|
inherit owner repo rev hash fetchSubmodules;
|
|
|
|
};
|
|
|
|
|
|
|
|
pulumi-gen = mkBasePackage rec {
|
2023-09-25 21:10:13 +00:00
|
|
|
inherit src version vendorHash extraLdflags env;
|
2022-10-18 12:39:31 +00:00
|
|
|
|
|
|
|
cmd = cmdGen;
|
|
|
|
pname = cmdGen;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
mkBasePackage ({
|
2023-09-25 21:10:13 +00:00
|
|
|
inherit meta src version vendorHash extraLdflags env;
|
2022-10-18 12:39:31 +00:00
|
|
|
|
|
|
|
pname = repo;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pulumi-gen
|
|
|
|
];
|
|
|
|
|
|
|
|
cmd = cmdRes;
|
|
|
|
|
|
|
|
postConfigure = ''
|
|
|
|
pushd ..
|
|
|
|
|
|
|
|
chmod +w sdk/
|
|
|
|
${cmdGen} schema
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
VERSION=v${version} go generate cmd/${cmdRes}/main.go
|
|
|
|
'';
|
2022-10-18 15:06:05 +00:00
|
|
|
|
|
|
|
passthru.sdks.python = mkPythonPackage {
|
|
|
|
inherit meta src version;
|
|
|
|
|
|
|
|
pname = repo;
|
|
|
|
};
|
2022-10-18 12:39:31 +00:00
|
|
|
} // args)
|