194 lines
12 KiB
Nix
194 lines
12 KiB
Nix
# This file is generated by running "yarn install" inside your project.
|
|
# Manual changes might be lost - proceed with caution!
|
|
|
|
{ lib, stdenv, nodejs, git, cacert, fetchurl, writeShellScript, writeShellScriptBin }:
|
|
{ src, overrideAttrs ? null, ... } @ args:
|
|
|
|
let
|
|
|
|
yarnBin = fetchurl {
|
|
url = "https://repo.yarnpkg.com/4.18.0/packages/yarnpkg-cli/bin/yarn.js";
|
|
hash = "sha512-/Lhxb+fNDuzhQf/Bi5IZOp35IEwbqDGJwoiDUiP8C75kr0c7qw1emSen2utcryuwfrJ4fMkzjKBA6hJfKh8vfg==";
|
|
};
|
|
|
|
cacheFolder = ".yarn/cache";
|
|
lockfile = ./yarn.lock;
|
|
|
|
# Call overrideAttrs on a derivation if a function is provided.
|
|
optionalOverride = fn: drv:
|
|
if fn == null then drv else drv.overrideAttrs fn;
|
|
|
|
# Simple stub that provides the global yarn command.
|
|
yarn = writeShellScriptBin "yarn" ''
|
|
exec '${nodejs}/bin/node' '${yarnBin}' "$@"
|
|
'';
|
|
|
|
# Common attributes between Yarn derivations.
|
|
drvCommon = {
|
|
# Make sure the build uses the right Node.js version everywhere.
|
|
buildInputs = [ nodejs yarn ];
|
|
# All dependencies should already be cached.
|
|
yarn_enable_network = "0";
|
|
# Tell node-gyp to use the provided Node.js headers for native code builds.
|
|
npm_config_nodedir = nodejs;
|
|
};
|
|
|
|
# Comman variables that we set in a Nix build, but not in a Nix shell.
|
|
buildVars = ''
|
|
# Make Yarn produce friendlier logging for automated builds.
|
|
export CI=1
|
|
# Tell node-pre-gyp to never fetch binaries / always build from source.
|
|
export npm_config_build_from_source=true
|
|
'';
|
|
|
|
# Create derivations for fetching dependencies.
|
|
cacheDrvs = let
|
|
in lib.mapAttrs (locator: { filename, hash }: stdenv.mkDerivation {
|
|
name = lib.strings.sanitizeDerivationName locator;
|
|
buildInputs = [ yarn git cacert ];
|
|
buildCommand = ''
|
|
cd '${src}'
|
|
${buildVars}
|
|
HOME="$TMP" yarn_enable_global_cache=false yarn_cache_folder="$TMP" \
|
|
yarn nixify fetch ${lib.escapeShellArg locator}
|
|
# Because we change the cache dir, Yarn may generate a different name.
|
|
mv "$TMP/$(sed 's/-[^-]*\.[^-]*$//' <<< "$outputFilename")"-* $out
|
|
'';
|
|
outputFilename = filename;
|
|
outputHash = hash;
|
|
}) cacheEntries;
|
|
|
|
# Create a shell snippet to copy dependencies from a list of derivations.
|
|
mkCacheBuilderForDrvs = drvs:
|
|
writeShellScript "collect-yarn-cache" (lib.concatMapStrings (drv: ''
|
|
cp --reflink=auto ${drv} '${drv.outputFilename}'
|
|
'') drvs);
|
|
|
|
# Main project derivation.
|
|
project = stdenv.mkDerivation (drvCommon // {
|
|
inherit src;
|
|
name = "@quixos/quixos-protocol";
|
|
|
|
configurePhase = ''
|
|
${buildVars}
|
|
|
|
# Copy over the Yarn cache.
|
|
rm -fr '${cacheFolder}'
|
|
mkdir -p '${cacheFolder}'
|
|
pushd '${cacheFolder}' > /dev/null
|
|
source ${mkCacheBuilderForDrvs (lib.attrValues cacheDrvs)}
|
|
popd > /dev/null
|
|
|
|
# Yarn may need a writable home directory.
|
|
export yarn_global_folder="$TMP"
|
|
|
|
# Ensure global cache is disabled. Cache must be part of our output.
|
|
touch .yarnrc.yml
|
|
sed -i -e '/^enableGlobalCache/d' .yarnrc.yml
|
|
echo 'enableGlobalCache: false' >> .yarnrc.yml
|
|
|
|
# Some node-gyp calls may call out to npm, which could fail due to an
|
|
# read-only home dir.
|
|
export HOME="$TMP"
|
|
|
|
# running preConfigure after the cache is populated allows for
|
|
# preConfigure to contain substituteInPlace for dependencies as well as the
|
|
# main project. This is necessary for native bindings that maybe have
|
|
# hardcoded values.
|
|
runHook preConfigure
|
|
|
|
# Run normal Yarn install to complete dependency installation.
|
|
yarn install --immutable --immutable-cache
|
|
|
|
runHook postConfigure
|
|
'';
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
# Move the package contents to the output directory.
|
|
if grep -q '"workspaces"' package.json; then
|
|
# We can't use `yarn pack` in a workspace setup, because it only
|
|
# packages the outer workspace.
|
|
mkdir -p "$out/libexec"
|
|
mv $PWD "$out/libexec/$name"
|
|
else
|
|
# - If the package.json has a `files` field, only files matching those patterns are copied
|
|
# - Otherwise all files are copied.
|
|
yarn pack --out package.tgz
|
|
mkdir -p "$out/libexec/$name"
|
|
tar xzf package.tgz --directory "$out/libexec/$name" --strip-components=1
|
|
|
|
cp --reflink=auto .yarnrc* "$out/libexec/$name"
|
|
cp --reflink=auto ${lockfile} "$out/libexec/$name/yarn.lock"
|
|
cp --reflink=auto --recursive .yarn "$out/libexec/$name"
|
|
|
|
# Copy the Yarn linker output into the package.
|
|
cp --reflink=auto --recursive node_modules "$out/libexec/$name"
|
|
fi
|
|
|
|
cd "$out/libexec/$name"
|
|
|
|
# Invoke a plugin internal command to setup binaries.
|
|
mkdir -p "$out/bin"
|
|
yarn nixify install-bin $out/bin
|
|
|
|
# A package with node_modules doesn't need the cache
|
|
yarn cache clean
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
passthru = {
|
|
inherit nodejs;
|
|
yarn-freestanding = yarn;
|
|
yarn = writeShellScriptBin "yarn" ''
|
|
exec '${yarn}/bin/yarn' --cwd '${overriddenProject}/libexec/${overriddenProject.name}' "$@"
|
|
'';
|
|
};
|
|
});
|
|
|
|
overriddenProject = optionalOverride overrideAttrs project;
|
|
|
|
cacheEntries = {
|
|
"@babel/helper-string-parser@npm:7.29.7" = { filename = "@babel-helper-string-parser-npm-7.29.7-87998d618e-194bc0f171.zip"; hash = "sha512-GUvA8XFuOW1f/eVq1hGXRfuVV2YsmGEVkOXkVJBng6TMshzpMFa462mkkJBEg05F2W5QrGlbvp4yIWSP4DPAbA=="; };
|
|
"@babel/helper-validator-identifier@npm:7.29.7" = { filename = "@babel-helper-validator-identifier-npm-7.29.7-9939aac13d-4795354e7a.zip"; hash = "sha512-R5U1Tnrg3K+nLeHNBOxRJS3BSYUXFwvq8BngPv/Ft78TxrIaOUmnfge4Elvn8QbtETE1DY69RWauh0CUpybWKw=="; };
|
|
"@babel/parser@npm:7.29.8" = { filename = "@babel-parser-npm-7.29.8-d8ac19f8b3-acc890c5e6.zip"; hash = "sha512-rMiQxeam3UCGOke1C6wRHXGF7m+74WPr4R1SFIVMoq25AUYq1NcYplCQ74S9IjDp6KtFouDKzMaF8fV6sLseKA=="; };
|
|
"@babel/types@npm:7.29.8" = { filename = "@babel-types-npm-7.29.8-3f9597fc63-be7c279f0a.zip"; hash = "sha512-vnwnnwq/KghsYz4htJx8qAJ10FKDzFomi2enCMmRS9DJRPFCKz6zyzdoKir11WCr9SDM+bAbU+y/5rcfvD/d5g=="; };
|
|
"@bufbuild/protobuf@npm:2.14.1" = { filename = "@bufbuild-protobuf-npm-2.14.1-78e9ea56a2-3f913aca03.zip"; hash = "sha512-P5E6ygPfhBnEsh2ADqVNf2yDalND5l1vaGJ57DVmxJB3KZOO8vlKXifZLo0/StzW4CcRi6Kbp2TSHhxjfN3HAg=="; };
|
|
"@bufbuild/protoc-gen-es@npm:2.14.1" = { filename = "@bufbuild-protoc-gen-es-npm-2.14.1-230b1181a2-79f9fad1d5.zip"; hash = "sha512-efn60dVmXaptZUmyh4oPY/6/rbGHuFNAg/vrI4Ydwizz6mmmYKEvD45Ps8AtJO6ALxcYRBVt5C+0sXEuOgZ1aQ=="; };
|
|
"@bufbuild/protoplugin@npm:2.14.1" = { filename = "@bufbuild-protoplugin-npm-2.14.1-ca1a20a987-6a727aa5a8.zip"; hash = "sha512-anJ6pahI4FA13tkPUOE65Sx3NXutalhHalbU/3ANyBPKxmTgzDC1IBNU5cFY6//rANyDUxbWaqLDhKLp2qXf4w=="; };
|
|
"@types/node@npm:24.13.3" = { filename = "@types-node-npm-24.13.3-b512a0bbeb-a5bc08f49b.zip"; hash = "sha512-pbwI9JuVgdzcqQ4CzXcZejx5mECAdmSULlzVFhpVPU0q6AZPfjKUQQ10jX0Ji1wYSL5/pQwG8pxBk6sWvk5Z6w=="; };
|
|
"@typescript/typescript-linux-arm64@npm:7.0.2" = { filename = "@typescript-typescript-linux-arm64-npm-7.0.2-9cacfc53a0-10c0.zip"; hash = "sha512-s4c7nGT/lQIw6x0IfrL0b3ECy/D0g7UoDLdiIWJoM6EGXk5N/dmXdxUdA8Cr3hV/3nO2BYKTQ6Ai8/zGhiSQ3A=="; };
|
|
"@typescript/typescript-linux-x64@npm:7.0.2" = { filename = "@typescript-typescript-linux-x64-npm-7.0.2-8dd7ff8d24-10c0.zip"; hash = "sha512-k9EUK5CZ3OOPnyslp8SAAonHJpnpPmlaulppI/NmFyCzNs3UN/TLPUkyQia3KIxgbyTzKoXI5L5fl8Uj9bJ7Cg=="; };
|
|
"@typescript/vfs@npm:1.6.4" = { filename = "@typescript-vfs-npm-1.6.4-78935c9d3e-acb9de42f2.zip"; hash = "sha512-rLneQvI/2j9149eQC6EG7zI6L0588OSpTbtFfibTU8pjuzUZPtGjL8hzPzrlkJlhKykLBr1iIWlIYb65v7YvYg=="; };
|
|
"antlr-ng@npm:1.0.10" = { filename = "antlr-ng-npm-1.0.10-840fe729e4-0893eda0fd.zip"; hash = "sha512-CJPtoP3M4dMpwYykUaxo7zdA+pOnISq5cq66bDNyLJvnL1dqN5cakOTnJSu6241VnAiH8yWPr+pZtJlsb+9P6g=="; };
|
|
"antlr4ng@npm:3.0.15" = { filename = "antlr4ng-npm-3.0.15-58a4d495ba-75421480b9.zip"; hash = "sha512-dUIUgLmWAcCuF0HkFHuF4k6egiNuw1TFH75QsthdcTeJRAW0dIk5xH5yCAC9GcChkAa49o+14Bg2xxf6vaaLXA=="; };
|
|
"antlr4ng@npm:3.0.16" = { filename = "antlr4ng-npm-3.0.16-c4e3e7474c-01b51d1d73.zip"; hash = "sha512-AbUdHXPKEvIt/Pcjuj12n0ewLDJhi8cp470iczT6FUoKQLFrDj0fJF+ldWv067uU3rKWoj1z8FLckL5qLEd9EQ=="; };
|
|
"base64-js@npm:1.5.1" = { filename = "base64-js-npm-1.5.1-b2f7275641-f23823513b.zip"; hash = "sha512-8jgjUTtjFzoAEDD65PLavig7manTJK3jrT0UjiGBNGdvHuhWjId8157BxTFY3PLSulJ6l8YGYYkoupndkwECvw=="; };
|
|
"commander@npm:13.1.0" = { filename = "commander-npm-13.1.0-bdbbfaaf9d-7b8c5544bb.zip"; hash = "sha512-e4xVRLunBPvoS3yrLgQ9+FhtXBFKTFtgf4OuUGBwiUDtC1vVg4z4zidTnN4mXBy9Wc48jGsBftPuyJQ+OkFRZA=="; };
|
|
"debug@npm:4.4.3" = { filename = "debug-npm-4.4.3-0105c6123a-d79136ec6c.zip"; hash = "sha512-15E27GyD7L79D2pVk9pqnJHsTX3cS1TIg9bnHsmsy19noaXpbQCjKBlrW1yG02XpjYo6cIVqrxa057GYXmf1pg=="; };
|
|
"fast-printf@npm:1.6.10" = { filename = "fast-printf-npm-1.6.10-c05cca9b81-630cccbef8.zip"; hash = "sha512-YwzMvvg0mm7q2plYyTkenRS1vZUn3SjZ5+nylbAGxkDdyo/CRwz/VepcbJLKUwSIu62/fCT0hSrYw02RVdqddQ=="; };
|
|
"graphql@npm:16.11.0" = { filename = "graphql-npm-16.11.0-836e6ade28-124da7860a.zip"; hash = "sha512-Ek2nhgoikums8v7Qxx/A9qm5yoZdOQ0RK91WPB9HQ1cUFQHBKJH0Fk/phDFXZHNq1n9wUhnGL3WAaB1DGoXbiA=="; };
|
|
"he@npm:1.2.0" = { filename = "he-npm-1.2.0-3b73a2ff07-a27d478bef.zip"; hash = "sha512-on1Hi+/jyBkvAGzdBjmmZ5iXnfpuISXGrFgqGaXr/sYq2D6DguYDYXDYc/RuRTan55W/i5W/fCR/TMCCXMyMFw=="; };
|
|
"luxon@npm:3.5.0" = { filename = "luxon-npm-3.5.0-92bb977f7f-335789bba9.zip"; hash = "sha512-M1eJu6lQd9uDHvmYlO2t6yMCOz6yE3obVqzQ0pAIK2kc95MUPWnjC8Bp7JXwtJ82QZ9I6VHGgBTxn/4SBF40lA=="; };
|
|
"ms@npm:2.1.3" = { filename = "ms-npm-2.1.3-81ff3cfac1-d924b57e73.zip"; hash = "sha512-2SS1fnMSs7Y60h/Fs9wK9eeNYaH8fPtUV+2vJjJr9ivlMHzIf/toYu8cKzOwIzzbXU8BxMlYzA1mCUi2Wih6SA=="; };
|
|
"pako@npm:0.2.9" = { filename = "pako-npm-0.2.9-c88ac0d326-79c1806ebc.zip"; hash = "sha512-ecGAbrzzJbYK5Znk1yJ8LjRte4Kdwg9c8kzvB8k0B53DphxbPIJ4ovehkMSmE+ND6hHlMC2+JS79EXEt9LawQQ=="; };
|
|
"stringtemplate4ts@npm:1.0.9" = { filename = "stringtemplate4ts-npm-1.0.9-df48ae4223-c5f46367d0.zip"; hash = "sha512-xfRjZ9A3XBp8ryC4YZCEL0rv+1Q9dosicN/TxeQsTc9JkBwCp7BowI6MREDAKiApCFlOvO2+0PXolHA9I/VMAg=="; };
|
|
"tiny-inflate@npm:1.0.3" = { filename = "tiny-inflate-npm-1.0.3-a7419a5c65-fab6875372.zip"; hash = "sha512-+raHU3JU9uxEyaLogASP5w2jVCq6KPc82j50yVyr80KjOTcvKmwDLjIjJPAazMA8omwEuiutmz64zz7pm7p/mw=="; };
|
|
"typescript@npm:5.4.5" = { filename = "typescript-npm-5.4.5-8568a42232-2954022ada.zip"; hash = "sha512-KVQCKto0D9PWqeK45TT2XVfJLV85iaJjdUp4q6VJ9+ZSmswZIZE1YKS4FsRtzn30pNKfnxGj3A1CE7t20EMlHg=="; };
|
|
"typescript@npm:7.0.2" = { filename = "typescript-npm-7.0.2-0bde2bcec5-3dcee51ec8.zip"; hash = "sha512-Pc7lHsjDMkkjJbzb999ItmZodR8SfmIq59QbbHFusZGEQkpF4U93UPUPNAIyOItp5ih4WRVfBqXOLfdvEssxzw=="; };
|
|
"typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=5adc0c" = { filename = "typescript-patch-6e159bfddb-db2ad2a16c.zip"; hash = "sha512-2yrSoWyoKfUEJ+6x2hVeekXlmO7HsIbYtOi6ROWiNfdY5gbWgcZpkiMNP8O4mVhl5f0LIqLJVIbQsyAPgwcuyQ=="; };
|
|
"typescript@patch:typescript@npm%3A7.0.2#optional!builtin<compat/typescript>::version=7.0.2&hash=3bafbf" = { filename = "typescript-patch-4859cbaf66-6b3cdc369c.zip"; hash = "sha512-azzcNpzYKdRuAHNOpkIz7oRBnCglrY/kCJFa3ed6vO1LeiQB9+7VF9VKek9dHBhpdTy5kBjfHCFZx2HZ8zSDpg=="; };
|
|
"undici-types@npm:7.18.2" = { filename = "undici-types-npm-7.18.2-3e6d69d829-85a7918911.zip"; hash = "sha512-haeRiRE6I4lZ16ZHNo5PfFVZw6QE69uPxEiBRc6UJvzYIlKoRKMCeY38Djfm+xeP9IHtA7xMr2NMV1fZ70NSHQ=="; };
|
|
"unicode-properties@npm:1.4.1" = { filename = "unicode-properties-npm-1.4.1-122054452f-1d140b7945.zip"; hash = "sha512-HRQLeUVmT7DvU96VUXCCHgd7lJ7vN3xuSQWQLwfjOQOScb+ioAXk9MYHSwgNNCC0hsUtyQXhH5JJSaBNH7R//Q=="; };
|
|
"unicode-trie@npm:2.0.0" = { filename = "unicode-trie-npm-2.0.0-54e0a4dd52-2422368645.zip"; hash = "sha512-JCI2hkUknzFWQKHJ6VBgRqp3OPycXVnhXCB83W7GYQHDWwufddw6wo/nvhmq8e/ImLvqB0+h6OKV73Nq63kEuw=="; };
|
|
};
|
|
|
|
in overriddenProject
|