shell.nix 2 KB
Newer Older
1
{ pkgs ? import ./nix/pinned.nix {} }:
2
let
3
  easy-ps = import ./nix/easy-ps.nix { inherit pkgs; };
4 5 6

  purs-packages = import ./purs-packages.nix { inherit pkgs; };

7
  purs-project = import ./nix/purs-project.nix { inherit pkgs; };
8 9 10

  build-purs = pkgs.writeShellScriptBin "build-purs" ''
    #!/usr/bin/env bash
11
    purs compile ${toString purs-project.sourceGlobs} "src/**/*.purs" "test/**/*.purs"
12
  '';
13 14 15

  build = pkgs.writeShellScriptBin "build" ''
    #!/usr/bin/env bash
16 17
    set -e

18
    echo "Compiling"
19
    build-purs
20 21 22
    echo "Bundling"
    yarn pulp browserify --skip-compile -t dist/bundle.js --src-path output
  '';
Przemyslaw Kaminski's avatar
Przemyslaw Kaminski committed
23 24 25 26 27 28

  repl = pkgs.writeShellScriptBin "repl" ''
    #!/usr/bin/env bash

    yarn pulp repl
  '';
29 30 31 32 33 34 35 36 37

  test-ps = pkgs.writeShellScriptBin "test-ps" ''
    #!/usr/bin/env bash
    set -e

    echo "Compiling"
    build-purs
    echo "Testing"
    # yarn pulp browserify --skip-compile -t dist/bundle.js --src-path output
38 39
    # yarn pulp test --src-path output --test-path output
    NODE_PATH=output node -e "require('Test.Main').main();"
40
  '';
41 42 43 44 45
in
pkgs.mkShell {
  buildInputs = [
    easy-ps.purs
    easy-ps.psc-package
46
    easy-ps.dhall-json-simple
47
    build-purs
48
    build
Przemyslaw Kaminski's avatar
Przemyslaw Kaminski committed
49
    repl
50
    pkgs.yarn
51
    test-ps
52
  ];
53 54 55 56

  shellHook = ''
    export PURS_IDE_SOURCES='${toString purs-project.unquotedSourceGlobs}'
  '';
57 58 59 60 61 62
}

## how to build the project with nix dependencies:
#
# 1. start a nix shell (e.g. `nix-shell -j 20`, this uses 20 jobs to fetch deps)
# 2. run `yarn` to install npm deps
63 64
# 3a. run `build-purs` to build using nix store dependencies, and make sure to update your purescript ide tooling as necesssary
# 3b. or simply use `psc-package` as you might want to anyway
65 66 67 68 69 70
#
# note that the purescript compiler uses filepaths and timestamps, so using the above two commands
# interchangeably will lead to constant rebuilding of the entire project.
#
## how to update purs-packages.nix
#
71 72
# 1. run `nix/generate-packages-json.nix` to generate packages.json
# 2. run `nix/generate-purs-packages.nix` to generate purs-packages.nix