Migrate from mkYarnPackage to fetchYarnDeps + yarnConfigHook

yarn2nix and mkYarnPackage were removed from nixpkgs; replace with
stdenv.mkDerivation using the new fetchYarnDeps offline cache and
yarnConfigHook.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Sonnet 4.6 committed 2026-05-02 04:49:35 -07:00
1 parent ce598d02f2
commit 44080b1e84
1 file changed
+15 -25
+15 -25
View File
@@ -9,43 +9,33 @@
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = {
permittedInsecurePackages = [
"nodejs-16.20.2"
];
};
};
pkgs = import nixpkgs { inherit system; };
in
{
packages.default = pkgs.mkYarnPackage {
packages.default = pkgs.stdenv.mkDerivation {
name = "spazer";
src = ./.;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
doDist = false;
offlineCache = pkgs.fetchYarnDeps {
yarnLock = ./yarn.lock;
hash = "sha256-dqgDWYSp4XII7rryZ7uH5cLnZkmKewz6XyxzZzRujC4=";
};
nativeBuildInputs = with pkgs; [
nodejs
yarn
yarnConfigHook
];
buildPhase = ''
# Parcel needs a HOME directory
export HOME=$(mktemp -d)
yarn parcel build
yarn build
'';
installPhase = ''
# Create output directory and copy files
mkdir -p $out
cp -r deps/Spazer/dist/. $out/
cp -r dist/. $out/
'';
buildInputs = with pkgs; [
nodejs
];
nativeBuildInputs = with pkgs; [
yarn
python3 # Sometimes needed by node-gyp
];
};
# Development shell with required dependencies