packages/excalidraw: switch to mkYarnPackage

This commit is contained in:
Max Headroom 2023-07-20 00:05:54 +02:00
parent caa5bd56b9
commit 4692b9900f
2 changed files with 69 additions and 20 deletions

View file

@ -12,10 +12,6 @@
./websites/landing/project.nix
./websites/stop-using-nix-env/project.nix
];
dream2nix.config = {
projectRoot = ./.;
overridesDirs = [ ./dream2nix-overrides ];
};
perSystem = { config, filters, pkgs, self', ... }:
let
inherit (self'.packages) nix-super;
@ -23,26 +19,11 @@
pins = import ./sources;
in
{
dream2nix = {
inputs = filters.doFilter filters.packages {
excalidraw = {
source = pins.excalidraw;
projects.excalidraw = {
subsystem = "nodejs";
translator = "yarn-lock";
subsystemInfo.nodejs = "18";
};
};
};
};
packages = filters.doFilter filters.packages rec {
cinny = pkgs.callPackage ./web-apps/cinny { inherit pins; };
excalidraw = let
inherit (config.dream2nix.outputs.excalidraw.packages) excalidraw;
in excalidraw // { webroot = "${excalidraw}/${excalidraw.webPath}"; };
excalidraw = pkgs.callPackage ./web-apps/excalidraw { inherit pins; };
graf = pkgs.callPackage ./tools/graf { };

View file

@ -0,0 +1,68 @@
{ lib
, fetchFromGitHub
, mkYarnPackage
, fetchYarnDeps
, fixup_yarn_lock
, npins
, pins
}:
let
inherit (pins) excalidraw;
app = mkYarnPackage rec {
pname = "excalidraw";
version = "0.0.0+${builtins.substring 0 7 excalidraw.revision}";
REACT_APP_DISABLE_SENTRY = "true";
REACT_APP_FIREBASE_CONFIG = "";
REACT_APP_GOOGLE_ANALYTICS_ID = "";
src = npins.mkSource excalidraw;
packageJSON = "${excalidraw}/package.json";
nativeBuildInputs = [ fixup_yarn_lock ];
offlineCache = fetchYarnDeps {
name = "excalidraw-yarn-cache-${builtins.hashString "sha256" (builtins.readFile "${excalidraw}/yarn.lock")}";
yarnLock = src + "/yarn.lock";
hash = "sha256-PuMqjAFhl+IPnpZyOlRPFazQbU5yKHe2iQJNgq4Cvh0=";
};
configurePhase = ''
runHook preConfigure
export HOME="$TMPDIR"
yarn config --offline set yarn-offline-mirror "$offlineCache"
fixup_yarn_lock yarn.lock
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
runHook postConfigure
'';
buildPhase = ''
yarn --offline build:app
'';
installPhase = ''
distRoot=$out/share/www
dist=$distRoot/excalidraw
mkdir -p $distRoot
mv build $dist
find $dist -type f -name "*.map" -delete
'';
doDist = false;
passthru.webroot = "${app}/share/www/excalidraw";
meta = with lib; {
description = "Virtual whiteboard for sketching hand-drawn like diagrams";
homepage = "https://github.com/excalidraw/excalidraw";
changelog = "https://github.com/excalidraw/excalidraw/blob/${src.rev}/CHANGELOG.md";
license = licenses.mit;
};
};
in app