on master help sign in
New project function
commitd76deb2a5ca4a2d068ae20554ceaac4d6aa9036d authorRyan Trinkle <ryan.trinkle@gmail.com> dateThu 28 Dec 2017, 22:31 (9 years ago) parent095e55b
1 file changed+43−4
default.nix+43−4
default.nix+43−4
@@ -1,7 +1,46 @@
11{}:
2−let
3− reflex-platform = import ./reflex-platform {};
2+let reflex-platform = import ./reflex-platform {};
43in
5−{
6− inherit (reflex-platform) project;
4+with reflex-platform.nixpkgs.lib;
5+rec {
6+ inherit reflex-platform;
7+ nullIfAbsent = p: if pathExists p then p else null;
8+ # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
9+ project =
10+ { base ? ./..
11+ , android ? null #TODO: Better error when missing
12+ , ios ? null #TODO: Better error when missing
13+ }: reflex-platform.project ({ ... }:
14+ let frontendName = "frontend";
15+ backendName = "backend";
16+ commonName = "common";
17+ packages = filterAttrs (_: x: x != null) {
18+ ${frontendName} = nullIfAbsent (base + "/frontend");
19+ ${commonName} = nullIfAbsent (base + "/common");
20+ ${backendName} = nullIfAbsent (base + "/backend");
21+ };
22+ in {
23+ inherit packages;
24+ shells = {
25+ ghc = filter (x: hasAttr x packages) [
26+ backendName
27+ commonName
28+ frontendName
29+ ];
30+ ghcjs = filter (x: hasAttr x packages) [
31+ frontendName
32+ commonName
33+ ];
34+ };
35+ android = {
36+ ${if android == null then null else frontendName} = {
37+ executableName = "frontend";
38+ } // android;
39+ };
40+ ios = {
41+ ${if ios == null then null else frontendName} = {
42+ executableName = "frontend";
43+ } // ios;
44+ };
45+ });
746}