fetch-yarn-deps: format with nixfmt (RFC166)

This commit is contained in:
Doron Behar 2024-07-03 09:27:59 +03:00
parent e691f848a2
commit 1151b39c24

View File

@ -1,4 +1,16 @@
{ stdenv, lib, makeWrapper, coreutils, nix-prefetch-git, fetchurl, nodejs-slim, prefetch-yarn-deps, cacert, callPackage, nix }: {
stdenv,
lib,
makeWrapper,
coreutils,
nix-prefetch-git,
fetchurl,
nodejs-slim,
prefetch-yarn-deps,
cacert,
callPackage,
nix,
}:
let let
yarnpkg-lockfile-tar = fetchurl { yarnpkg-lockfile-tar = fetchurl {
@ -6,9 +18,9 @@ let
hash = "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ=="; hash = "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==";
}; };
tests = callPackage ./tests {}; tests = callPackage ./tests { };
in
in { {
prefetch-yarn-deps = stdenv.mkDerivation { prefetch-yarn-deps = stdenv.mkDerivation {
name = "prefetch-yarn-deps"; name = "prefetch-yarn-deps";
@ -30,12 +42,20 @@ in {
patchShebangs $out/libexec patchShebangs $out/libexec
makeWrapper $out/libexec/index.js $out/bin/prefetch-yarn-deps \ makeWrapper $out/libexec/index.js $out/bin/prefetch-yarn-deps \
--prefix PATH : ${lib.makeBinPath [ coreutils nix-prefetch-git nix ]} --prefix PATH : ${
lib.makeBinPath [
coreutils
nix-prefetch-git
nix
]
}
runHook postInstall runHook postInstall
''; '';
passthru = { inherit tests; }; passthru = {
inherit tests;
};
}; };
fixup-yarn-lock = stdenv.mkDerivation { fixup-yarn-lock = stdenv.mkDerivation {
@ -63,45 +83,75 @@ in {
runHook postInstall runHook postInstall
''; '';
passthru = { inherit tests; }; passthru = {
inherit tests;
};
}; };
fetchYarnDeps = let fetchYarnDeps =
f = { let
name ? "offline", f =
src ? null, {
hash ? "", name ? "offline",
sha256 ? "", src ? null,
... hash ? "",
}@args: let sha256 ? "",
hash_ = ...
if hash != "" then { outputHashAlgo = null; outputHash = hash; } }@args:
else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; } let
else { outputHashAlgo = "sha256"; outputHash = lib.fakeSha256; }; hash_ =
in stdenv.mkDerivation ({ if hash != "" then
inherit name; {
outputHashAlgo = null;
outputHash = hash;
}
else if sha256 != "" then
{
outputHashAlgo = "sha256";
outputHash = sha256;
}
else
{
outputHashAlgo = "sha256";
outputHash = lib.fakeSha256;
};
in
stdenv.mkDerivation (
{
inherit name;
dontUnpack = src == null; dontUnpack = src == null;
dontInstall = true; dontInstall = true;
nativeBuildInputs = [ prefetch-yarn-deps cacert ]; nativeBuildInputs = [
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; prefetch-yarn-deps
NODE_EXTRA_CA_CERTS = "${cacert}/etc/ssl/certs/ca-bundle.crt"; cacert
];
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
NODE_EXTRA_CA_CERTS = "${cacert}/etc/ssl/certs/ca-bundle.crt";
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
yarnLock=''${yarnLock:=$PWD/yarn.lock} yarnLock=''${yarnLock:=$PWD/yarn.lock}
mkdir -p $out mkdir -p $out
(cd $out; prefetch-yarn-deps --verbose --builder $yarnLock) (cd $out; prefetch-yarn-deps --verbose --builder $yarnLock)
runHook postBuild runHook postBuild
''; '';
outputHashMode = "recursive"; outputHashMode = "recursive";
} // hash_ // (removeAttrs args (["name" "hash" "sha256"] ++ (lib.optional (src == null) "src")))); }
// hash_
in lib.setFunctionArgs f (lib.functionArgs f) // { // (removeAttrs args (
inherit tests; [
}; "name"
"hash"
"sha256"
]
++ (lib.optional (src == null) "src")
))
);
in
lib.setFunctionArgs f (lib.functionArgs f) // { inherit tests; };
} }