git.iko.soy/typeable/octopod
on anisimoffnikita/go-helm-octopod help sign in
62 lines 1.9 kB history raw
1{ sources ? import ../nix/sources.nix
2, haskellNix ? import sources.haskellNix { }
3, pkgsSrc ? import haskellNix.sources.nixpkgs-2105
4, pkgs ? pkgsSrc (haskellNix.nixpkgsArgs // { })
5, config ? {}
6}:
8with (pkgs);
10let
11 mkDerivation =
12 { srcs ? ./elm-srcs.nix
13 , src
14 , name
15 , srcdir ? "./src"
16 , targets ? []
17 , registryDat ? ./registry.dat
18 , outputJavaScript ? false
19 }:
20 stdenv.mkDerivation {
21 inherit name src;
23 buildInputs = [ elmPackages.elm ]
24 ++ lib.optional outputJavaScript nodePackages.uglify-js;
26 buildPhase = pkgs.elmPackages.fetchElmDeps {
27 elmPackages = import srcs;
28 elmVersion = "0.19.1";
29 inherit registryDat;
30 };
33 installPhase = let
34 elmfile = module: "${srcdir}/${builtins.replaceStrings ["."] ["/"] module}.elm";
35 extension = if outputJavaScript then "js" else "html";
36 octopod-css = import ../octopod-css { inherit pkgsSrc; };
37 index = "./index.html";
38 in ''
39 mkdir -p $out
40 cp ${index} $out/index.html
41 cp -av ${octopod-css}/* $out
43 mkdir -p $out/share/doc
44 ${lib.concatStrings (map (module: ''
45 echo "compiling ${elmfile module}"
46 elm make ${elmfile module} --output $out/${module}.${extension} --docs $out/share/doc/${module}.json
47 ${lib.optionalString outputJavaScript ''
48 echo "minifying ${elmfile module}"
49 uglifyjs $out/${module}.${extension} --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' \
50 | uglifyjs --mangle --output $out/${module}.min.${extension}
51 ''}
52 '') targets)}
53 '';
54 };
55in mkDerivation {
56 name = "elm-app-0.1.0";
57 srcs = ./elm-srcs.nix;
58 src = ./.;
59 targets = ["Main"];
60 srcdir = "./src";
61 outputJavaScript = true;