@@ -1,26 +1,49 @@
1−{}:
2−let reflex-platform = import ./reflex-platform {};
1+{ system ? builtins.currentSystem }:
2+let reflex-platform = import ./reflex-platform { inherit system; };
3+ pkgs = reflex-platform.nixpkgs;
34in
4−with reflex-platform.nixpkgs.lib;
5+with pkgs.lib;
56rec {
67 inherit reflex-platform;
78 nullIfAbsent = p: if pathExists p then p else null;
9+ #TODO: Avoid copying files within the nix store. Right now, obelisk-asset-manifest-generate copies files into a big blob so that the android/ios static assets can be imported from there; instead, we should get everything lined up right before turning it into an APK, so that copies, if necessary, only exist temporarily.
10+ processAssets = { src, packageName ? "static", moduleName ? "Static" }: pkgs.runCommand "asset-manifest" {
11+ inherit src;
12+ outputs = [ "out" "haskellManifest" "symlinked" ];
13+ buildInputs = [
14+ (reflex-platform.ghc.callCabal2nix "obelisk-asset-manifest" ./asset/manifest {})
15+ ];
16+ } ''
17+ set -euo pipefail
18+ touch "$out"
19+ obelisk-asset-manifest-generate "$src" "$haskellManifest" ${packageName} ${moduleName} "$symlinked"
20+ '';
821 # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
922 project =
1023 { base ? ./..
1124 , android ? null #TODO: Better error when missing
1225 , ios ? null #TODO: Better error when missing
13− }: reflex-platform.project ({ ... }:
26+ }: reflex-platform.project ({ nixpkgs, ... }: with nixpkgs.haskell.lib;
1427 let frontendName = "frontend";
1528 backendName = "backend";
1629 commonName = "common";
30+ staticName = "static";
31+ staticPath = base + "/static";
32+ assets = processAssets { src = base + "/static"; };
1733 packages = filterAttrs (_: x: x != null) {
1834 ${frontendName} = nullIfAbsent (base + "/frontend");
1935 ${commonName} = nullIfAbsent (base + "/common");
2036 ${backendName} = nullIfAbsent (base + "/backend");
37+ obelisk-asset-serve = ./asset/serve;
38+ obelisk-asset-manifest = ./asset/manifest;
39+ obelisk-backend = ./backend;
40+ };
41+ overrides = self: super: {
42+ heist = doJailbreak super.heist; #TODO: Move up to reflex-platform; create tests for r-p supported packages
43+ ${staticName} = dontHaddock (self.callCabal2nix "static" assets.haskellManifest {});
2144 };
2245 in {
23− inherit packages;
46+ inherit packages overrides;
2447 shells = {
2548 ghc = filter (x: hasAttr x packages) [
2649 backendName
@@ -35,11 +58,13 @@ rec {
3558 android = {
3659 ${if android == null then null else frontendName} = {
3760 executableName = "frontend";
61+ ${if builtins.pathExists staticPath then "assets" else null} = assets.symlinked;
3862 } // android;
3963 };
4064 ios = {
4165 ${if ios == null then null else frontendName} = {
4266 executableName = "frontend";
67+ #TODO: Static assets
4368 } // ios;
4469 };
4570 });