uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
89
pkgs/development/web/deno/default.nix
Normal file
89
pkgs/development/web/deno/default.nix
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
, rustPlatform
|
||||
, installShellFiles
|
||||
, libiconv
|
||||
, libobjc
|
||||
, Security
|
||||
, CoreServices
|
||||
, Metal
|
||||
, Foundation
|
||||
, QuartzCore
|
||||
, librusty_v8 ? callPackage ./librusty_v8.nix { }
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "deno";
|
||||
version = "1.22.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "denoland";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-HKuP3P7gBimzbhdEr2NwZNkp8hhkN7sJA9qRa0CDVew=";
|
||||
};
|
||||
cargoSha256 = "sha256-hxaqMcvwVeOSybqp10BzJOetVTwCx1mrUIP2H8WjCGw=";
|
||||
|
||||
postPatch = ''
|
||||
# upstream uses lld on aarch64-darwin for faster builds
|
||||
# within nix lld looks for CoreFoundation rather than CoreFoundation.tbd and fails
|
||||
substituteInPlace .cargo/config --replace '"-C", "link-arg=-fuse-ld=lld"' ""
|
||||
'';
|
||||
|
||||
# Install completions post-install
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
buildAndTestSubdir = "cli";
|
||||
|
||||
buildInputs = lib.optionals stdenv.isDarwin
|
||||
[ libiconv libobjc Security CoreServices Metal Foundation QuartzCore ];
|
||||
|
||||
# The v8 package will try to download a `librusty_v8.a` release at build time to our read-only filesystem
|
||||
# To avoid this we pre-download the file and export it via RUSTY_V8_ARCHIVE
|
||||
RUSTY_V8_ARCHIVE = librusty_v8;
|
||||
|
||||
# Tests have some inconsistencies between runs with output integration tests
|
||||
# Skipping until resolved
|
||||
doCheck = false;
|
||||
|
||||
preInstall = ''
|
||||
find ./target -name libswc_common${stdenv.hostPlatform.extensions.sharedLibrary} -delete
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd deno \
|
||||
--bash <($out/bin/deno completions bash) \
|
||||
--fish <($out/bin/deno completions fish) \
|
||||
--zsh <($out/bin/deno completions zsh)
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
$out/bin/deno --help
|
||||
$out/bin/deno --version | grep "deno ${version}"
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update/update.ts;
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://deno.land/";
|
||||
changelog = "https://github.com/denoland/deno/releases/tag/v${version}";
|
||||
description = "A secure runtime for JavaScript and TypeScript";
|
||||
longDescription = ''
|
||||
Deno aims to be a productive and secure scripting environment for the modern programmer.
|
||||
Deno will always be distributed as a single executable.
|
||||
Given a URL to a Deno program, it is runnable with nothing more than the ~15 megabyte zipped executable.
|
||||
Deno explicitly takes on the role of both runtime and package manager.
|
||||
It uses a standard browser-compatible protocol for loading modules: URLs.
|
||||
Among other things, Deno is a great replacement for utility scripts that may have been historically written with
|
||||
bash or python.
|
||||
'';
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ jk ];
|
||||
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
};
|
||||
}
|
||||
21
pkgs/development/web/deno/librusty_v8.nix
Normal file
21
pkgs/development/web/deno/librusty_v8.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# auto-generated file -- DO NOT EDIT!
|
||||
{ rust, stdenv, fetchurl }:
|
||||
|
||||
let
|
||||
arch = rust.toRustTarget stdenv.hostPlatform;
|
||||
fetch_librusty_v8 = args: fetchurl {
|
||||
name = "librusty_v8-${args.version}";
|
||||
url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${arch}.a";
|
||||
sha256 = args.shas.${stdenv.hostPlatform.system};
|
||||
meta = { inherit (args) version; };
|
||||
};
|
||||
in
|
||||
fetch_librusty_v8 {
|
||||
version = "0.43.1";
|
||||
shas = {
|
||||
x86_64-linux = "sha256-xsKV3/MXwQExON5Bq1qRUShPV0wXEtUHB/DTVjVyWfQ=";
|
||||
aarch64-linux = "sha256-wBtpDG4GxSR4jeAZjclNqVDankWBmxf0cH0LKM4smjM=";
|
||||
x86_64-darwin = "sha256-BGrbwRoPUcSIW4Q3PF8p6vjkTKGLISBxLjOXDWcSjag=";
|
||||
aarch64-darwin = "sha256-4OyQPQPIQ94TanY1hxRTdcWZi5didvyLupLfQ516YL4=";
|
||||
};
|
||||
}
|
||||
55
pkgs/development/web/deno/update/common.ts
Normal file
55
pkgs/development/web/deno/update/common.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
interface GHRelease {
|
||||
tag_name: string;
|
||||
}
|
||||
|
||||
const decode = (buffer: Uint8Array) => new TextDecoder("utf-8").decode(buffer);
|
||||
const decodeTrim = (b: Uint8Array) => decode(b).trimEnd();
|
||||
export const run = async (command: string, args: string[]) => {
|
||||
const cmd = Deno.run({
|
||||
cmd: [command, ...args],
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
});
|
||||
if (!(await cmd.status()).success) {
|
||||
const error = await cmd.stderrOutput().then(decodeTrim);
|
||||
// Known error we can ignore
|
||||
if (error.includes("'allow-unsafe-native-code-during-evaluation'")) {
|
||||
// Extract the target sha256 out of the error
|
||||
const target = " got: sha256:";
|
||||
const match = error
|
||||
.split("\n")
|
||||
.find((l) => l.includes(target))
|
||||
?.split(target)[1];
|
||||
if (typeof match !== "undefined") {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
throw new Error(error);
|
||||
}
|
||||
return cmd.output().then(decodeTrim);
|
||||
};
|
||||
|
||||
// Exports
|
||||
export const versionRegExp = /\d+\.\d+\.\d+/;
|
||||
export const sha256RegExp = /[a-z0-9]{52}|sha256-.{44}/;
|
||||
|
||||
export const getExistingVersion = async (filePath: string) =>
|
||||
read(filePath).then(
|
||||
(s) => s.match(genValueRegExp("version", versionRegExp))?.shift() || "",
|
||||
);
|
||||
|
||||
export const getLatestVersion = (owner: string, repo: string) =>
|
||||
fetch(`https://api.github.com/repos/${owner}/${repo}/releases`)
|
||||
.then((res) => res.json())
|
||||
.then((res: GHRelease[]) => res[0].tag_name);
|
||||
|
||||
// The (?<=) and (?=) allow replace to only change inside
|
||||
// Match the regex passed in or empty
|
||||
export const genValueRegExp = (key: string, regex: RegExp) =>
|
||||
new RegExp(`(?<=${key} = ")(${regex.source}|)(?=")`);
|
||||
|
||||
export const logger = (name: string) =>
|
||||
(...a: any) => console.log(`[${name}]`, ...a);
|
||||
|
||||
export const read = Deno.readTextFile;
|
||||
export const write = Deno.writeTextFile;
|
||||
90
pkgs/development/web/deno/update/librusty_v8.ts
Normal file
90
pkgs/development/web/deno/update/librusty_v8.ts
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import {
|
||||
genValueRegExp,
|
||||
getExistingVersion,
|
||||
logger,
|
||||
run,
|
||||
versionRegExp,
|
||||
write,
|
||||
} from "./common.ts";
|
||||
|
||||
const log = logger("librusty_v8");
|
||||
|
||||
export interface Architecture {
|
||||
nix: string;
|
||||
rust: string;
|
||||
}
|
||||
interface PrefetchResult {
|
||||
arch: Architecture;
|
||||
sha256: string;
|
||||
}
|
||||
|
||||
const getLibrustyV8Version = 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("v8", versionRegExp))?.shift());
|
||||
|
||||
const fetchArchShaTasks = (version: string, arches: Architecture[]) =>
|
||||
arches.map(
|
||||
async (arch: Architecture): Promise<PrefetchResult> => {
|
||||
log("Fetching:", arch.nix);
|
||||
const sha256 = await run("nix-prefetch", [
|
||||
`
|
||||
{ fetchurl }:
|
||||
fetchurl {
|
||||
url = "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!
|
||||
{ rust, stdenv, fetchurl }:
|
||||
|
||||
let
|
||||
arch = rust.toRustTarget stdenv.hostPlatform;
|
||||
fetch_librusty_v8 = args: fetchurl {
|
||||
name = "librusty_v8-\${args.version}";
|
||||
url = "https://github.com/denoland/rusty_v8/releases/download/v\${args.version}/librusty_v8_release_\${arch}.a";
|
||||
sha256 = args.shas.\${stdenv.hostPlatform.system};
|
||||
meta = { inherit (args) version; };
|
||||
};
|
||||
in
|
||||
fetch_librusty_v8 {
|
||||
version = "${version}";
|
||||
shas = {
|
||||
${deps.map(({ arch, sha256 }) => ` ${arch.nix} = "${sha256}";`).join("\n")}
|
||||
};
|
||||
}
|
||||
`;
|
||||
|
||||
export async function updateLibrustyV8(
|
||||
filePath: string,
|
||||
owner: string,
|
||||
repo: string,
|
||||
denoVersion: string,
|
||||
arches: Architecture[],
|
||||
) {
|
||||
log("Starting librusty_v8 update");
|
||||
// 0.0.0
|
||||
const version = await getLibrustyV8Version(owner, repo, denoVersion);
|
||||
if (typeof version !== "string") {
|
||||
throw "no librusty_v8 version";
|
||||
}
|
||||
log("librusty_v8 version:", version);
|
||||
const existingVersion = await getExistingVersion(filePath);
|
||||
if (version === existingVersion) {
|
||||
log("Version already matches latest, skipping...");
|
||||
return;
|
||||
}
|
||||
const archShaResults = await Promise.all(fetchArchShaTasks(version, arches));
|
||||
await write(filePath, templateDeps(version, archShaResults));
|
||||
log("Finished deps update");
|
||||
}
|
||||
67
pkgs/development/web/deno/update/src.ts
Normal file
67
pkgs/development/web/deno/update/src.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import {
|
||||
genValueRegExp,
|
||||
logger,
|
||||
read,
|
||||
run,
|
||||
sha256RegExp,
|
||||
versionRegExp,
|
||||
write,
|
||||
} from "./common.ts";
|
||||
|
||||
interface Replacer {
|
||||
regex: RegExp;
|
||||
value: string;
|
||||
}
|
||||
|
||||
const log = logger("src");
|
||||
|
||||
const prefetchSha256 = (nixpkgs: string, version: string) =>
|
||||
run("nix-prefetch", ["-f", nixpkgs, "deno.src", "--rev", version]);
|
||||
const prefetchCargoSha256 = (nixpkgs: string) =>
|
||||
run(
|
||||
"nix-prefetch",
|
||||
[`{ sha256 }: (import ${nixpkgs} {}).deno.cargoDeps.overrideAttrs (_: { inherit sha256; })`],
|
||||
);
|
||||
|
||||
const replace = (str: string, replacers: Replacer[]) =>
|
||||
replacers.reduce(
|
||||
(str, r) => str.replace(r.regex, r.value),
|
||||
str,
|
||||
);
|
||||
|
||||
const updateNix = (filePath: string, replacers: Replacer[]) =>
|
||||
read(filePath).then((str) => write(filePath, replace(str, replacers)));
|
||||
|
||||
const genVerReplacer = (k: string, value: string): Replacer => (
|
||||
{ regex: genValueRegExp(k, versionRegExp), value }
|
||||
);
|
||||
const genShaReplacer = (k: string, value: string): Replacer => (
|
||||
{ regex: genValueRegExp(k, sha256RegExp), value }
|
||||
);
|
||||
|
||||
export async function updateSrc(
|
||||
filePath: string,
|
||||
nixpkgs: string,
|
||||
denoVersion: string,
|
||||
) {
|
||||
log("Starting src update");
|
||||
const trimVersion = denoVersion.substr(1);
|
||||
log("Fetching sha256 for:", trimVersion);
|
||||
const sha256 = await prefetchSha256(nixpkgs, denoVersion);
|
||||
log("sha256 to update:", sha256);
|
||||
await updateNix(
|
||||
filePath,
|
||||
[
|
||||
genVerReplacer("version", trimVersion),
|
||||
genShaReplacer("sha256", sha256),
|
||||
],
|
||||
);
|
||||
log("Fetching cargoSha256 for:", sha256);
|
||||
const cargoSha256 = await prefetchCargoSha256(nixpkgs);
|
||||
log("cargoSha256 to update:", cargoSha256);
|
||||
await updateNix(
|
||||
filePath,
|
||||
[genShaReplacer("cargoSha256", cargoSha256)],
|
||||
);
|
||||
log("Finished src update");
|
||||
}
|
||||
43
pkgs/development/web/deno/update/update.ts
Executable file
43
pkgs/development/web/deno/update/update.ts
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
/*
|
||||
#!nix-shell -i "deno run --allow-net --allow-run --allow-read --allow-write" -p deno git nix-prefetch
|
||||
*/
|
||||
import { getExistingVersion, getLatestVersion, logger } from "./common.ts";
|
||||
import { Architecture, updateLibrustyV8 } from "./librusty_v8.ts";
|
||||
import { updateSrc } from "./src.ts";
|
||||
|
||||
const log = logger("update");
|
||||
// TODO: Getting current file position to more-safely point to nixpkgs root
|
||||
const nixpkgs = Deno.cwd();
|
||||
// TODO: Read values from default.nix
|
||||
const owner = "denoland";
|
||||
const repo = "deno";
|
||||
const denoDir = `${nixpkgs}/pkgs/development/web/${repo}`;
|
||||
const src = `${denoDir}/default.nix`;
|
||||
const librusty_v8 = `${denoDir}/librusty_v8.nix`;
|
||||
const architectures: Architecture[] = [
|
||||
{ nix: "x86_64-linux", rust: "x86_64-unknown-linux-gnu" },
|
||||
{ nix: "aarch64-linux", rust: "aarch64-unknown-linux-gnu" },
|
||||
{ nix: "x86_64-darwin", rust: "x86_64-apple-darwin" },
|
||||
{ nix: "aarch64-darwin", rust: "aarch64-apple-darwin" },
|
||||
];
|
||||
|
||||
log("Updating deno");
|
||||
|
||||
log("Getting latest deno version");
|
||||
const version = await getLatestVersion(owner, repo);
|
||||
const existingVersion = await getExistingVersion(src);
|
||||
const trimVersion = version.substr(1); // Strip v from v0.0.0
|
||||
log("Latest version: ", trimVersion);
|
||||
log("Extracted version:", existingVersion);
|
||||
if (trimVersion === existingVersion) {
|
||||
log("Version already matches latest, skipping...");
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
const tasks = [
|
||||
updateSrc(src, nixpkgs, version),
|
||||
updateLibrustyV8(librusty_v8, owner, repo, version, architectures),
|
||||
];
|
||||
await Promise.all(tasks);
|
||||
log("Updating deno complete");
|
||||
Loading…
Add table
Add a link
Reference in a new issue