Skip to content

Commit

Permalink
shift things around
Browse files Browse the repository at this point in the history
  • Loading branch information
shmish111 committed Oct 17, 2019
1 parent 6fbcb85 commit b126df8
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 107 deletions.
45 changes: 2 additions & 43 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -448,50 +448,9 @@ let
exit
'';

updateClientDepsScript = baseDirectory:
let
setup = pkgs.callPackage ./web-common/deps.nix { inherit baseDirectory; };
in
pkgs.writeScript "update-client-deps" ''
#!${pkgs.runtimeShell}
updateMarlowePlaygroundClientDeps = pkgs.callPackage ./web-common/deps.nix { inherit nixGitIgnore easyPS; baseDirectory = ./marlowe-playground-client; };

set -eou pipefail
export PATH=${pkgs.stdenv.lib.makeBinPath [
pkgs.coreutils
pkgs.git
pkgs.findutils
pkgs.nodejs-10_x
easyPS.purs
easyPS.psc-package
easyPS.spago
easyPS.spago2nix
]}
if [ ! -f package.json ]
then
echo "package.json not found. Please run this script from the client directory." >&2
exit 1
fi
echo Remove old JavaScript Dependencies
rm -Rf node_modules : true
echo Installing JavaScript Dependencies
mkdir node_modules
cp -R ${setup}/node_modules/* ./node_modules
chown -R `whoami` node_modules
chmod -R +w node_modules
cat ${setup}/yarn.lock > yarn.lock
cat ${setup}/yarn.nix > yarn.nix
echo Generate nix files
spago2nix generate
echo Done
'';
updateMarlowePlaygroundClientDeps = updateClientDepsScript ./marlowe-playground-client;
updatePlutusPlaygroundClientDeps = updateClientDepsScript ./plutus-playground-client;
updatePlutusPlaygroundClientDeps = pkgs.callPackage ./web-common/deps.nix { inherit nixGitIgnore easyPS; baseDirectory = ./plutus-playground-client; };
};

withDevTools = env: env.overrideAttrs (attrs: { nativeBuildInputs = attrs.nativeBuildInputs ++
Expand Down
135 changes: 71 additions & 64 deletions web-common/deps.nix
Original file line number Diff line number Diff line change
@@ -1,74 +1,81 @@
{ system
, config
, pkgs
, nixGitIgnore
, easyPS
, baseDirectory
}:
let

nixGitIgnore = import (pkgs.fetchFromGitHub {
owner = "siers";
repo = "nix-gitignore";
rev = "686b057f6c24857c8862c0ef15a6852caab809c7";
sha256 = "1hv8jl7ppv0f8lnfx2qi2jmzc7b5yiy12yvd4waq9xmxhip1k7rb";
}) { inherit (pkgs) lib runCommand; };

easyPS = import (pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "cc7196bff3fdb5957aabfe22c3fa88267047fe88";
sha256 = "1xfl7rnmmcm8qdlsfn3xjv91my6lirs5ysy01bmyblsl10y2z9iw";
}) { pkgs = pkgs // { nix-gitignore = nixGitIgnore; }; };

node_modules = pkgs.stdenv.mkDerivation {
name = "node_modules";
srcs = builtins.filterSource (path: type: baseNameOf path == "package.json") baseDirectory;
buildInputs = [ pkgs.yarn
];
buildPhase = ''
yarn
'';
installPhase = ''
mkdir -p $out
cp yarn.lock $out/
cp -r node_modules $out/
'';
deps = pkgs.stdenv.mkDerivation {
name = "deps";
srcs = builtins.filterSource (path: type: pkgs.lib.elem (baseNameOf path) ["package.json" "spago.dhall" "packages.dhall"]) baseDirectory;
buildInputs = [
pkgs.coreutils
pkgs.python2
pkgs.nodejs-10_x
pkgs.nodePackages_10_x.node-gyp
pkgs.yarn
pkgs.yarn2nix
easyPS.purs
easyPS.psc-package
easyPS.spago
easyPS.spago2nix
pkgs.which
pkgs.git
];
buildPhase = ''
yarn
yarn2nix > yarn.nix
export HOME=$(pwd)
# spago init
# spago list-packages -f transitive -j
# spago -v sources
# spago2nix generate
'';
installPhase = ''
mkdir -p $out
cp yarn.lock $out/
cp -r node_modules $out/
cp yarn.nix $out/
'';
};
in
pkgs.stdenv.mkDerivation {
name = "deps";
srcs = builtins.filterSource (path: type: pkgs.lib.elem (baseNameOf path) ["package.json" "spago.dhall" "packages.dhall"]) baseDirectory;
buildInputs = [
pkgs.coreutils
pkgs.python2
pkgs.nodejs-10_x
pkgs.nodePackages_10_x.node-gyp
pkgs.yarn
pkgs.yarn2nix
easyPS.purs
easyPS.psc-package
easyPS.spago
easyPS.spago2nix
pkgs.which
pkgs.git
];
buildPhase = ''
cp -r ${node_modules}/node_modules .
cat ${node_modules}/yarn.lock > yarn.lock
ls -la
yarn2nix > yarn.nix
echo "spago"
export HOME=$(pwd)
# spago init
# spago list-packages -f transitive -j
# spago -v sources
pkgs.writeScript "update-client-deps" ''
#!${pkgs.runtimeShell}
set -eou pipefail
export PATH=${pkgs.stdenv.lib.makeBinPath [
pkgs.coreutils
pkgs.git
pkgs.findutils
pkgs.nodejs-10_x
easyPS.purs
easyPS.psc-package
easyPS.spago
easyPS.spago2nix
]}
if [ ! -f package.json ]
then
echo "package.json not found. Please run this script from the client directory." >&2
exit 1
fi
echo Remove old JavaScript Dependencies
rm -Rf node_modules : true
echo Installing JavaScript Dependencies
mkdir node_modules
cp -R ${deps}/node_modules/* ./node_modules
chown -R `whoami` node_modules
chmod -R +w node_modules
cat ${deps}/yarn.lock > yarn.lock
cat ${deps}/yarn.nix > yarn.nix
echo Generate nix files
spago2nix generate
# spago2nix generate
'';
installPhase = ''
ls -la
mkdir -p $out
cp yarn.lock $out/
cp -r node_modules $out/
cp yarn.nix $out/
'';
}
echo Done
''

0 comments on commit b126df8

Please sign in to comment.