on master help sign in
executable-config: Add default.nix for lookup haskell package; properly set platform flags
commit547cf43cc874485ba88aa703c5448308208d938c authorAli Abrar <aliabrar@gmail.com> dateFri 16 Feb 2018, 14:14 (9 years ago) parentfb6ecab
3 files changed+51−10
lib/executable-config/default.nix+8−3 lib/executable-config/lookup/default.nix+26 lib/executable-config/lookup/obelisk-executable-config.cabal+17−7
lib/executable-config/default.nix+8−3
@@ -1,5 +1,9 @@
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.
15{ nixpkgs
2−, filterGitSource
6+, filterGitSource # TODO define this in obelisk
37}:
48let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} ''
59 set -x
@@ -12,8 +16,7 @@ let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} ''
1216 cp -a "${config}"/* "$out/config"
1317 '';
1418in with nixpkgs.haskell.lib; {
15− haskellPackage = self:
16− self.callCabal2nix "obelisk-executable-config" (filterGitSource ./lookup) {};
19+ haskellPackage = self: self.callPackage (filterGitSource ./hs) {};
1720 platforms = {
1821 android = {
1922 # Inject the given config directory into an android assets folder
@@ -23,5 +26,7 @@ in with nixpkgs.haskell.lib; {
2326 # Inject the given config directory into an iOS app
2427 inject = injectConfig;
2528 };
29+ web = {
30+ };
2631 };
2732}
lib/executable-config/lookup/default.nixnew file+26
@@ -0,0 +1,26 @@
1+{ hostPlatform, mkDerivation, base, bytestring, filepath, stdenv, text
2+, transformers, android-activity, jsaddle-wkwebview
3+}:
4+let isAndroid = hostPlatform.libc == "bionic";
5+ isIOS = hostPlatform.isDarwin && hostPlatform.isAArch64;
6+in mkDerivation {
7+ pname = "obelisk-executable-config";
8+ version = "0.1";
9+ src = ./.;
10+ libraryHaskellDepends = [
11+ base bytestring filepath text transformers
12+ ] ++ (if isAndroid then [
13+ android-activity
14+ ] else if isIOS then [
15+ jsaddle-wkwebview
16+ ] else [
17+ ]);
18+ configureFlags = if isAndroid then [
19+ "-fandroid"
20+ ] else if isIOS then [
21+ "-fios"
22+ ] else [
23+ ];
24+ license = stdenv.lib.licenses.bsd3;
25+}
26+
lib/executable-config/lookup/obelisk-executable-config.cabal+17−7
@@ -3,18 +3,28 @@ version: 0.1
33cabal-version: >= 1.2
44build-type: Simple
55
6+flag ios
7+ description: Build for ios
8+ default: False
9+ manual: True
10+
11+flag android
12+ description: Build for android
13+ default: False
14+ manual: True
15+
616library
717 hs-source-dirs: src
8− if os(darwin) || os(ios)
18+ if flag(ios)
919 hs-source-dirs: src-ios
1020 build-depends: jsaddle-wkwebview
1121 else
12− hs-source-dirs: src-android
13− c-sources: cbits/ExecutableConfig.c
14− other-modules: Obelisk.ExecutableConfig.Internal.AssetManager
15− build-depends:
16− android-activity
17− ld-options: -landroid
22+ if flag(android)
23+ hs-source-dirs: src-android
24+ c-sources: cbits/ExecutableConfig.c
25+ other-modules: Obelisk.ExecutableConfig.Internal.AssetManager
26+ build-depends: android-activity
27+ ld-options: -landroid
1828
1929 build-depends:
2030 base,