diff options
author | Alyssa Ross <hi@alyssa.is> | 2020-07-13 23:20:04 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-07-13 23:21:06 +0000 |
commit | a42c1d6d62656dcf9bd85de620f2e200a5ad22d8 (patch) | |
tree | 7d481fea9872f62a034452612be17f4494159baa /nixpkgs/pkgs/development/web/deno/update/deps.ts | |
parent | 55f69a6b0e53c1c4b3e0396937c53bf5662b5519 (diff) | |
parent | 9480bae337095fd24f61380bce3174fdfe926a00 (diff) | |
download | nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.tar nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.tar.gz nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.tar.bz2 nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.tar.lz nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.tar.xz nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.tar.zst nixlib-a42c1d6d62656dcf9bd85de620f2e200a5ad22d8.zip |
Merge commit '9480bae337095fd24f61380bce3174fdfe926a00'
This is the last nixos-unstable release before 13b2903169f, which I'm a bit nervous about. So I want the update including that one to be as small as possible, hence going to this one first.
Diffstat (limited to 'nixpkgs/pkgs/development/web/deno/update/deps.ts')
-rw-r--r-- | nixpkgs/pkgs/development/web/deno/update/deps.ts | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/web/deno/update/deps.ts b/nixpkgs/pkgs/development/web/deno/update/deps.ts new file mode 100644 index 000000000000..beedeade3a86 --- /dev/null +++ b/nixpkgs/pkgs/development/web/deno/update/deps.ts @@ -0,0 +1,79 @@ +import { + getExistingVersion, + genValueRegExp, + logger, + nixPrefetchURL, + versionRegExp, + write, +} from "./common.ts"; + +const log = logger("deps"); + +export interface Architecture { + nix: string; + rust: string; +} +interface PrefetchResult { + arch: Architecture; + sha256: string; +} + +const getRustyV8Version = async ( + owner: string, + repo: string, + version: string, +) => + fetch( + `https://github.com/${owner}/${repo}/raw/${version}/core/Cargo.toml`, + ) + .then((res) => res.text()) + .then((txt) => + txt.match(genValueRegExp("rusty_v8", versionRegExp))?.shift() + ); + +const archShaTasks = (version: string, arches: Architecture[]) => + arches.map(async (arch: Architecture): Promise<PrefetchResult> => { + log("Fetching:", arch.nix); + const sha256 = await nixPrefetchURL( + [`https://github.com/denoland/rusty_v8/releases/download/v${version}/librusty_v8_release_${arch.rust}.a`], + ); + log("Done: ", arch.nix); + return { arch, sha256 }; + }); + +const templateDeps = (version: string, deps: PrefetchResult[]) => + `# auto-generated file -- DO NOT EDIT! +{}: +rec { + rustyV8Lib = { + version = "${version}"; + sha256s = { +${deps.map((d) => ` ${d.arch.nix} = "${d.sha256}";`).join("\n")} + }; + }; +} +`; + +export async function updateDeps( + filePath: string, + owner: string, + repo: string, + denoVersion: string, + arches: Architecture[], +) { + log("Starting deps update"); + // 0.0.0 + const version = await getRustyV8Version(owner, repo, denoVersion); + if (typeof version !== "string") { + throw "no rusty_v8 version"; + } + log("rusty_v8 version:", version); + const existingVersion = await getExistingVersion(filePath); + if (version === existingVersion) { + log("Version already matches latest, skipping..."); + return; + } + const archShaResults = await Promise.all(archShaTasks(version, arches)); + await write(filePath, templateDeps(version, archShaResults)); + log("Finished deps update"); +} |