Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from input-output-hk/SRE-124_implement_yarn_w…
…orkspaces [SRE 124] Use local offline cache
- Loading branch information
Showing
7 changed files
with
91 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,59 @@ | ||
{ mkYarnPackage | ||
, lib | ||
, cardano-graphql-src | ||
, runtimeShell | ||
{ stdenv | ||
, nix-inclusive | ||
, nodejs | ||
, python | ||
, nodePackages | ||
, runtimeShell | ||
, sources | ||
, yarn | ||
}: | ||
|
||
let | ||
packageJSON = cardano-graphql-src + "/package.json"; | ||
version = (__fromJSON (__readFile packageJSON)).version; | ||
|
||
in mkYarnPackage { | ||
pname = "cardano-graphql"; | ||
inherit packageJSON version; | ||
yarnLock = cardano-graphql-src + "/yarn.lock"; | ||
src = lib.cleanSourceWith { | ||
filter = name: type: let | ||
baseName = baseNameOf (toString name); | ||
sansPrefix = lib.removePrefix (toString ../.) name; | ||
in_blacklist = | ||
lib.hasPrefix "/node_modules" sansPrefix || | ||
lib.hasPrefix "/build" sansPrefix || | ||
lib.hasPrefix "/.git" sansPrefix; | ||
in_whitelist = | ||
(type == "directory") || | ||
(lib.hasSuffix ".yml" name) || | ||
(lib.hasSuffix ".ts" name) || | ||
(lib.hasSuffix ".json" name) || | ||
(lib.hasSuffix ".graphql" name) || | ||
baseName == "package.json" || | ||
baseName == "yarn.lock" || | ||
(lib.hasPrefix "/deploy" sansPrefix); | ||
in ( | ||
(!in_blacklist) && in_whitelist | ||
); | ||
src = cardano-graphql-src; | ||
packageJSON = builtins.fromJSON (builtins.readFile ../package.json); | ||
|
||
src = stdenv.mkDerivation { | ||
pname = "${packageJSON.name}-src"; | ||
version = packageJSON.version; | ||
buildInputs = [ yarn nodejs ]; | ||
src = nix-inclusive ./.. [ | ||
../yarn.lock | ||
../.yarnrc | ||
../package.json | ||
../packages | ||
../packages-cache | ||
../tsconfig.json | ||
../docker-compose.yml | ||
]; | ||
buildCommand = '' | ||
mkdir -p $out | ||
cp -r $src/. $out/ | ||
cd $out | ||
chmod -R u+w . | ||
yarn --offline --frozen-lockfile --non-interactive | ||
''; | ||
}; | ||
yarnPreBuild = '' | ||
mkdir -p $HOME/.node-gyp/${nodejs.version} | ||
echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion | ||
ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version} | ||
''; | ||
|
||
installPhase = '' | ||
export PATH="$PATH:$node_modules/.bin" | ||
in stdenv.mkDerivation { | ||
pname = packageJSON.name; | ||
version = packageJSON.version; | ||
inherit src; | ||
buildInputs = [ nodejs yarn ]; | ||
buildCommand = '' | ||
mkdir -p $out | ||
cp -r $src/. $out/ | ||
chmod -R u+w $out | ||
patchShebangs $out | ||
yarn run build | ||
cd $out | ||
pwd | ||
ls -hal | ||
cp -r deps/cardano-graphql/packages/server/dist $out | ||
yarn build | ||
find . -name node_modules -type d -print0 | xargs -0 rm -rf | ||
yarn --production --offline --frozen-lockfile --non-interactive | ||
mkdir -p $out/bin | ||
cat <<EOF > $out/bin/cardano-graphql | ||
#!${runtimeShell} | ||
exec ${nodejs}/bin/node $out/index.js | ||
exec ${nodejs}/bin/node $out/packages/server/dist/index.js | ||
EOF | ||
chmod +x $out/bin/cardano-graphql | ||
''; | ||
|
||
distPhase = '' | ||
cp -r . $out | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ mkDerivation, base, deepseq, HUnit, parsec, stdenv | ||
, test-framework, test-framework-hunit, test-framework-quickcheck2 | ||
}: | ||
mkDerivation { | ||
pname = "network-uri"; | ||
version = "2.6.1.0"; | ||
sha256 = "423e0a2351236f3fcfd24e39cdbc38050ec2910f82245e69ca72a661f7fc47f0"; | ||
revision = "1"; | ||
editedCabalFile = "141nj7q0p9wkn5gr41ayc63cgaanr9m59yym47wpxqr3c334bk32"; | ||
libraryHaskellDepends = [ base deepseq parsec ]; | ||
testHaskellDepends = [ | ||
base HUnit test-framework test-framework-hunit | ||
test-framework-quickcheck2 | ||
]; | ||
homepage = "https://github.com/haskell/network-uri"; | ||
description = "URI manipulation"; | ||
license = stdenv.lib.licenses.bsd3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters