wip: frontend-package
This commit is contained in:
parent
62217c30f6
commit
d4801653ca
|
@ -1,10 +1,89 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
}: stdenv.mkDerivation {
|
||||
{ stdenv
|
||||
, fetchFromGitHub
|
||||
, fetchYarnDeps
|
||||
, fixup-yarn-lock
|
||||
, nodejs
|
||||
, yarn
|
||||
}: let
|
||||
buildJS = { pname, version, src, yarnHash, packagePath, buildCmd ? "build" }: stdenv.mkDerivation {
|
||||
inherit pname version src;
|
||||
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = "${src}/yarn.lock";
|
||||
hash = yarnHash;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ fixup-yarn-lock nodejs yarn ];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
export HOME=$NIX_BUILD_TOP/fake_home
|
||||
yarn config --offline set yarn-offline-mirror $offlineCache
|
||||
fixup-yarn-lock yarn.lock
|
||||
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
|
||||
patchShebangs node_modules/
|
||||
patchShebangs packages/${packagePath}/node_modules/
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
pushd packages/${packagePath}
|
||||
yarn --offline ${buildCmd}
|
||||
popd
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mv packages/${packagePath}/dist $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
algoliaInstantsearchJS = buildJS rec {
|
||||
pname = "instantsearch";
|
||||
version = "4.73.2";
|
||||
src = fetchFromGitHub {
|
||||
owner = "algolia";
|
||||
repo = "instantsearch";
|
||||
rev = "instantsearch.js@${version}";
|
||||
hash = "sha256-Wu4q8PPbHlb77hSYIFnRg4FemRPjqEw4p7fSBc3gzQQ=";
|
||||
};
|
||||
yarnHash = "sha256-B1OP8Q+QMu6EkdeVkxiTpQY2halZmE8GhsbEJp1q4TQ=";
|
||||
packagePath = "instantsearch.js";
|
||||
buildCmd = "build:umd";
|
||||
};
|
||||
meilisearchInstant = buildJS rec {
|
||||
pname = "meilisearch-js-plugins";
|
||||
version = "0.19.1";
|
||||
src = fetchFromGitHub {
|
||||
owner = "meilisearch";
|
||||
repo = "meilisearch-js-plugins";
|
||||
rev = "@meilisearch/instant-meilisearch@${version}";
|
||||
hash = "sha256-KJOj9ZMtN4bwEy+0PKuziq+1gqMp9volNACn1XTA7AA=";
|
||||
};
|
||||
yarnHash = "sha256-zODub/XZzIoxwUHQhp+6S2vIg7P9K/rw9ZT02teM0fw=";
|
||||
packagePath = "instant-meilisearch";
|
||||
};
|
||||
in stdenv.mkDerivation {
|
||||
pname = "frontend";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
# todo
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
cp $src/index.html $out/
|
||||
cp -r ${algoliaInstantsearchJS}/instantsearch.production.min.js.map $out/
|
||||
cp -r ${algoliaInstantsearchJS}/instantsearch.production.min.js $out/
|
||||
cp -r ${meilisearchInstant}/instant-meilisearch.umd.min.js.map $out/
|
||||
cp -r ${meilisearchInstant}/instant-meilisearch.umd.min.js $out/
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue