default.nix 4.83 KB
Newer Older
1 2
with import <nixpkgs> { };

3 4
let

js@lastlog.de's avatar
js@lastlog.de committed
5 6
############## emscripten environment below #################################################

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
libz = stdenv.mkDerivation {
  name="libz";

  buildInputs = [ emscripten autoconf automake libtool pkgconfig gnumake ];

   src = fetchurl {
     url = "http://zlib.net/zlib-1.2.8.tar.gz";
     sha256 = "039agw5rqvqny92cpkrfn243x2gd4xn13hs3xi6isk55d2vqqr9n";
   };

  configurePhase = ''
    export EMCONFIGURE_JS=2 

    # Some tests require writing at $HOME
    HOME=$TMPDIR

    emconfigure ./configure --prefix=$out
  '';

  buildPhase = ''
    emmake make
  '';
};

json-c = stdenv.mkDerivation rec {
  name = "json-c";

  buildInputs = [ emscripten autoconf automake libtool pkgconfig gnumake ];
35

36 37 38 39 40
  version = "json-c-0.12-20140410";

  src = fetchgit {
    url = "https://github.com/json-c/json-c";
    rev = "refs/tags/${version}";
41
    sha256 = "1cj9qvsc8djgs0x9g3xb7szgjpmyqkw4gr3pf26qal35lv2wb1ig";
42
  };
43 44

  configurePhase = ''
45
    export EMCONFIGURE_JS=2
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

    # Some tests require writing at $HOME
    HOME=$TMPDIR

    ./autogen.sh
    emconfigure ./configure --prefix=$out
  '';

  buildPhase = ''
    emmake make
  '';

};

xml-js = stdenv.mkDerivation rec {
  name = "xml-js";

  buildInputs = [ emscripten autoconf automake libtool pkgconfig gnumake ];

65 66 67
  src = fetchgit {
    url = "https://github.com/kripken/xml.js";
    rev = "95addcf845fa8393f3d3b1a0f747404a1a51ec2c";
68
    sha256 = "1sj8y3aakvlhgrwwyhpyq2kn7h53gclck4w0mwvakh8k5fjlgff9";
69 70
  };

71
  configurePhase = ''
72
    cd libxml2
73
    export EMCONFIGURE_JS=2
74 75 76 77 78

    # Some tests require writing at $HOME
    HOME=$TMPDIR
    autoreconf -if -Wall

Paul's avatar
Paul committed
79 80
    emconfigure ../libxml2/configure --with-http=no --with-ftp=no --with-python=no --with-threads=no --prefix=$out CFLAGS='-O3' CXXFLAGS='-O3'
#--with-debug
81 82 83
  '';

  buildPhase = ''
Paul's avatar
Paul committed
84
    emmake make CFLAGS='-O3' CXXFLAGS='-O3'
85 86 87
  '';
};

js@lastlog.de's avatar
js@lastlog.de committed
88
# tested to work with emscripten 1.35.4
89 90 91
fastXmlLint = stdenv.mkDerivation rec {
  name = "fastXmlLint";

92 93 94
  buildInputs = [ json-c libz xml-js emscripten gnumake pkgconfig ];

  phases= [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "checkPhase" "installPhase" ] ;
95 96 97 98 99 100 101 102 103 104

  src = ./.;

  configurePhase = ''
    export EMCONFIGURE_JS=2

    # Some tests require writing at $HOME
    HOME=$TMPDIR
  '';

105
  # wrapping make using 'emmake' would remove the required exports for pkg-config to function properly
106
  buildPhase = ''
107
    make
108 109
  '';

110
  checkPhase = "";
111

js@lastlog.de's avatar
js@lastlog.de committed
112
  # this doesn't make much sense yet
113 114 115 116 117 118 119 120 121
  installPhase = ''
    mkdir $out/
    cp -R *.js* $out/
    cp -R *.xhtml $out/
    cp -R *.html $out/
    cp -R codemirror-5.12 $out/
    cp -R html5-rng $out/
    cp -R libreoffice-relax-ng-example $out/
  '';
122
};
123

js@lastlog.de's avatar
js@lastlog.de committed
124 125 126 127 128 129 130
emEnvironment = stdenv.mkDerivation rec {

  name = "emEnv";

  shellHook = ''
    export HISTFILE=".zsh_history"
    alias make="colormake -f Makefile.emEnv"
131
    alias c="while true; do inotifywait * -e modify --quiet > /dev/null; clear; make closure| head -n 30; done"
132
    alias s="python customserver.py"
js@lastlog.de's avatar
js@lastlog.de committed
133 134 135 136 137
    alias jcc=closure_compiler/jcc
    echo "welcome to the emEnvironment"
    PS1="emEnv: \$? \w \[$(tput sgr0)\]"
  '';

138
  buildInputs = [ json-c libz xml-js ] ++ [ colormake nodejs emscripten autoconf automake libtool pkgconfig gnumake strace ltrace python openjdk ncurses ];
js@lastlog.de's avatar
js@lastlog.de committed
139 140
};

js@lastlog.de's avatar
js@lastlog.de committed
141 142 143
############## emscripten environment above #################################################


144

145 146 147 148 149 150 151 152 153 154 155 156
############## native environment below #################################################

json-c-native = stdenv.mkDerivation rec {
  name = "json-c-native";

  buildInputs = [ autoconf automake libtool pkgconfig gnumake ];

  version = "json-c-0.12-20140410";

  src = fetchgit {
    url = "https://github.com/json-c/json-c";
    rev = "refs/tags/${version}";
157
    sha256 = "1cj9qvsc8djgs0x9g3xb7szgjpmyqkw4gr3pf26qal35lv2wb1ig";
158 159 160 161 162 163 164 165 166 167 168 169
  };

  configurePhase = ''
    ./autogen.sh
    sed 's/-Werror//g' -i Makefile.in linkhash.c Makefile.am.inc configure aclocal.m4
    ./configure --prefix=$out
  '';

  buildPhase = ''
    make
  '';
};
js@lastlog.de's avatar
js@lastlog.de committed
170

171
nativeEnvironment = stdenv.mkDerivation rec {
172
  buildInputs = [ json-c-native libxml2 nodejs colormake autoconf automake libtool pkgconfig gnumake strace ltrace python openjdk ncurses ];
173
  name = "nativeEnv";
174 175 176

  shellHook = ''
    export HISTFILE=".zsh_history"
177
    alias make="colormake -f Makefile.nativeEnv"
178
    alias c="while true; do inotifywait * -e modify --quiet > /dev/null; clear; make closure| head -n 30; done"
179
    alias s="python customserver.py"
180
    alias jcc=closure_compiler/jcc
181 182 183 184 185 186 187 188 189 190 191
    echo "welcome to the nativeEnvironment"
    PS1="nativeEnv: \$? \w \[$(tput sgr0)\]"
  '';


};

############## native environment above #################################################

in

192
{
193 194 195 196 197 198 199
  # use nix-shell with -A to select the wanted environment to work with:
  #   --pure is optional

  # nix-shell -A nativeEnv --pure  
  nativeEnv = nativeEnvironment;
  # nix-shell -A emEnv --pure  
  emEnv = emEnvironment;
200
}
201