Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Trinkle committed Jan 31, 2015
0 parents commit f333fb4
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist
cabal-dev
*.o
*.hi
*.chi
*.chs.h
.virtualenv
.hsenv
.cabal-sandbox/
cabal.sandbox.config
cabal.config
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "nixpkgs"]
path = nixpkgs
url = ../nixpkgs
[submodule "reflex"]
path = reflex
url = ../reflex
[submodule "reflex-dom"]
path = reflex-dom
url = ../reflex-dom
[submodule "reflex-todomvc"]
path = reflex-todomvc
url = ../reflex-todomvc
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2014, Ryan Trinkle
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ghcjs-setup
===========

```bash
git clone --recursive [email protected]:ryantrinkle/try-reflex
cd try-reflex
./try-reflex
```

This will install the Nix package manager, grab the ghcjs package information, build everything, then give you access to a sandbox with ghcjs and node.js available. The first time you run it, the build process will take a long time - up to several hours. After that, it should only take a few moments.

You will need sudo access in order to install Nix (unless you are on NixOS). However, you should run the script as yourself, not root - it will prompt for your password when necessary.
13 changes: 13 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let nixpkgs = import ./nixpkgs {};
extendHaskellPackages = haskellPackages: haskellPackages.override {
extension = self: super: {
reflex = self.callPackage ./reflex {};
reflexDom = self.callPackage ./reflex-dom {};
reflexTodomvc = self.callPackage ./reflex-todomvc {};
};
};
in {
inherit nixpkgs;
haskellPackages_ghc784 = extendHaskellPackages nixpkgs.pkgs.haskellPackages_ghc784_profiling;
haskellPackages_ghcjs = extendHaskellPackages nixpkgs.pkgs.haskellPackages_ghcjs;
}
1 change: 1 addition & 0 deletions nixpkgs
Submodule nixpkgs added at 141135
1 change: 1 addition & 0 deletions reflex
Submodule reflex added at c4cacc
1 change: 1 addition & 0 deletions reflex-dom
Submodule reflex-dom added at 020497
1 change: 1 addition & 0 deletions reflex-todomvc
Submodule reflex-todomvc added at 650bde
14 changes: 14 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ platform ? "ghcjs" }:
with import ./.;
let haskellPackages =
if platform == "ghcjs" then haskellPackages_ghcjs
else if platform == "ghc" then haskellPackages_ghc784
else error (''Unrecognized platform "${platform}"; please use either "ghcjs" or "ghc"'');
in nixpkgs.runCommand "shell" {
buildInputs = with haskellPackages; [
ghc (ghc.ghc.parent.cabalInstall or null) nixpkgs.nodejs
reflex
reflexDom
reflexTodomvc
];
} ""
55 changes: 55 additions & 0 deletions try-reflex
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -eu

REPO="https://github.com/ryantrinkle/try-reflex"

trap "echo 'It looks like a problem occurred. Please submit an issue at $REPO/issues'; exit 1" ERR

echo "If you have any trouble with this script, please submit an issue at $REPO/issues"

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

echo "In order to continue, $0 must install the Nix package manager. This requires root access, so you will be prompted for your password. If you do not wish to continue, just hit Ctrl-C at the password prompt."
bash <(curl https://nixos.org/nix/install)
fi

if ! type -P nix-shell >/dev/null ; then
. ~/.nix-profile/etc/profile.d/nix.sh
if ! type -P nix-shell >/dev/null ; then
echo "It looks like Nix isn't working. Please make sure you can run nix-shell, then retry the $0, or submit an issue at $REPO/issues"
exit 1
fi
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. You can verify that ghcjs is configured correctly by checking that you get expected output like this:
$ ghcjs --version
The Glorious Glasgow Haskell Compilation System for JavaScript, version 0.1.0 (GHC 7.8.4)
$ cabal 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 --command "echo \"$INFO\" ; return"

0 comments on commit f333fb4

Please sign in to comment.