<commit_before>#!/usr/bin/env bash
set -eu

trap "echo 'It looks like a problem occurred.  Please submit an issue at https://github.com/ryantrinkle/ghcjs-setup/issues'; exit 1" ERR

echo "If you have any trouble with this script, please submit an issue at https://github.com/ryantrinkle/ghcjs-setup/issues"

if [ ! -d /nix ] ; then
  if ! type -P curl ; then
    echo "Please make sure that 'curl' is installed and can be run from this shell"
    exit 1
  fi

  echo "Installing Nix"
  bash <(curl https://nixos.org/nix/install)
fi

if ! type -P nix-shell ; then
  . ~/.nix-profile/etc/profile.d/nix.sh
fi

if [ ! -d nixpkgs ] ; then
  if ! type -P git ; then
    echo "Please make sure that 'git' is installed and can be run from this shell"
    exit 1
  fi

  echo "Getting ghcjs build scripts"
  git clone https://github.com/ryantrinkle/nixpkgs
fi

INFO=$(cat <<"EOF"

You are now in a shell with access to ghcjs and cabal-js.  You can verify that ghcjs is configured correctly with:
$ ghcjs --version
The Glorious Glasgow Haskell Compilation System for JavaScript, version 0.1.0 (GHC 7.8.3)

$ cabal-js install --help | grep ghcjs
--ghcjs                         compile with GHCJS

To build a basic program with ghcjs, do:
$ echo 'main = putStrLn \"Hello, world!\"' > helloWorld.hs
$ ghcjs helloWorld.hs
$ node helloWorld.jsexe/all.js
EOF
)

echo "Entering the ghcjs/nodejs sandbox; this may take several hours the first time you run it"
nix-shell -I . -p haskellPackages_ghcjs.ghc haskellPackages_ghcjs.ghc.ghc.parent.cabalInstallGhcjs nodejs --command "echo \"$INFO\" ; return"<commit_msg>Switch to upstream nixpkgs repository, since ghcjs has now been merged<commit_after>#!/usr/bin/env bash
set -eu

trap "echo 'It looks like a problem occurred.  Please submit an issue at https://github.com/ryantrinkle/ghcjs-setup/issues'; exit 1" ERR

echo "If you have any trouble with this script, please submit an issue at https://github.com/ryantrinkle/ghcjs-setup/issues"

if [ ! -d /nix ] ; then
  if ! type -P curl ; then
    echo "Please make sure that 'curl' is installed and can be run from this shell"
    exit 1
  fi

  echo "Installing Nix"
  bash <(curl https://nixos.org/nix/install)
fi

if ! type -P nix-shell ; then
  . ~/.nix-profile/etc/profile.d/nix.sh
fi

if [ ! -d nixpkgs ] ; then
  if ! type -P git ; then
    echo "Please make sure that 'git' is installed and can be run from this shell"
    exit 1
  fi

  echo "Getting ghcjs build scripts"
  git clone https://github.com/NixOS/nixpkgs
fi

INFO=$(cat <<"EOF"

You are now in a shell with access to ghcjs and cabal-js.  You can verify that ghcjs is configured correctly with:
$ ghcjs --version
The Glorious Glasgow Haskell Compilation System for JavaScript, version 0.1.0 (GHC 7.8.3)

$ cabal-js install --help | grep ghcjs
--ghcjs                         compile with GHCJS

To build a basic program with ghcjs, do:
$ echo 'main = putStrLn \"Hello, world!\"' > helloWorld.hs
$ ghcjs helloWorld.hs
$ node helloWorld.jsexe/all.js
EOF
)

echo "Entering the ghcjs/nodejs sandbox; this may take several hours the first time you run it"
nix-shell -I . -p haskellPackages_ghcjs.ghc haskellPackages_ghcjs.ghc.ghc.parent.cabalInstall nodejs --command "echo \"$INFO\" ; return"
{'fraction_non_alphanumeric': 0.10098826436071649, 'fraction_numerical': 0.005558987029030266, 'mean_word_length': 3.2010376134889755, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2794864', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1102, 'n_words': 417}