on 1c26925 help sign in
56 lines 1.8 kB history raw
1# This module exposes a tool for several platforms that can be used to inject
2# configuration information into a canonical location. It also provides a haskell
3# package that can be used to retrieve the injected configuration on each supported
4# platform.
5{ lib
6, runCommand
7, obeliskCleanSource
8}:
10let
11 injectConfig = config: assets: runCommand "inject-config" {} (''
12 set -x
13 mkdir -p $out
14 cp --no-preserve=mode -Lr "${assets}" $out/static
15 chmod +w "$out"
16 '' + lib.optionalString (!(builtins.isNull config)) ''
17 if ! mkdir $out/config; then
18 2>&1 echo config directory already exists or could not be created
19 exit 1
20 fi
21 cp -a "${config}"/* "$out/config"
22 # Needed for android deployments
23 find "$out/config" -type f -printf '%P\0' > "$out/config.files"
24 '');
25in
28 haskellOverlay = self: super:
29 let
30 pkgs = self.callPackage ({pkgs}: pkgs) {};
31 in {
32 obelisk-executable-config-lookup = pkgs.haskell.lib.overrideCabal
33 (self.callCabal2nix "obelisk-executable-config-lookup" (obeliskCleanSource ./lookup) {})
34 (drv: {
35 # Hack until https://github.com/NixOS/cabal2nix/pull/432 lands
36 libraryHaskellDepends = (drv.libraryHaskellDepends or [])
37 ++ pkgs.stdenv.lib.optionals (with pkgs.stdenv.hostPlatform; isAndroid && is32bit) [
38 self.android-activity
39 ];
40 });
41 };
43 platforms = {
44 android = {
45 # Inject the given config directory into an android assets folder
46 inject = injectConfig;
47 };
48 ios = {
49 # Inject the given config directory into an iOS app
50 inject = injectConfig;
51 };
52 web = {
53 inject = self: self.callCabal2nix "obelisk-executable-config-inject" (obeliskCleanSource ./inject) {};
54 };
55 };