on master help sign in
Merge branch 'master' into eac-custom-server-imports
commitf02db72619164249fee1bfb2f82dd8af45b13a54 authorLuigy Leon <luichi.19@gmail.com> dateThu 27 Sep 2018, 17:57 (8 years ago) parentbc44567e769565
4 files changed+48−40
default.nix+18−11 lib/executable-config/lookup/src-android/Obelisk/ExecutableConfig.hs+1−1 lib/executable-config/lookup/src-ios/Obelisk/ExecutableConfig.hs+1−1 release.nix+28−27
default.nix+18−11
@@ -5,8 +5,8 @@
55let
66 getReflexPlatform = sys: import ./dep/reflex-platform { inherit iosSdkVersion; system = sys; };
77 reflex-platform = getReflexPlatform system;
8− inherit (reflex-platform) hackGet;
9− pkgs = reflex-platform.nixpkgs;
8+ inherit (reflex-platform) hackGet nixpkgs;
9+ pkgs = nixpkgs;
1010in with pkgs.haskell.lib; with pkgs.lib;
1111let
1212 # TODO: Remove this after updating nixpkgs: https://github.com/NixOS/nixpkgs/issues/37750
@@ -115,7 +115,7 @@ let
115115 obelisk-cliapp = self.callCabal2nix "obelisk-cliapp" (cleanSource ./lib/cliapp) {};
116116 obelisk-command = (self.callCabal2nix "obelisk-command" (cleanSource ./lib/command) {}).override { Cabal = super.Cabal_2_0_0_2; };
117117 obelisk-executable-config = executableConfig.haskellPackage self;
118− obelisk-executable-config-inject = executableConfig.platforms.web.inject self; # TODO handle platforms.{ios,android}
118+ obelisk-executable-config-inject = executableConfig.platforms.web.inject self;
119119 obelisk-migration = self.callCabal2nix "obelisk-migration" (cleanSource ./lib/migration) {};
120120 obelisk-run = self.callCabal2nix "obelisk-run" (cleanSource ./lib/run) {};
121121 obelisk-selftest = self.callCabal2nix "obelisk-selftest" (cleanSource ./lib/selftest) {};
@@ -274,9 +274,9 @@ rec {
274274
275275 # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
276276 project = base: projectDefinition:
277− let assets = processAssets { src = base + "/static"; };
278− configPath = base + "/config";
279−
277+ let configPath = base + "/config";
278+ static = base + "/static";
279+ processedStatic = processAssets { src = static; };
280280 projectOut = sys: (getReflexPlatform sys).project (args@{ nixpkgs, ... }:
281281 let mkProject = { android ? null #TODO: Better error when missing
282282 , ios ? null #TODO: Better error when missing
@@ -300,10 +300,16 @@ rec {
300300 };
301301 combinedPackages = predefinedPackages // packages;
302302 projectOverrides = self: super: {
303− ${staticName} = dontHaddock (self.callCabal2nix "static" assets.haskellManifest {});
303+ ${staticName} = dontHaddock (self.callCabal2nix "static" processedStatic.haskellManifest {});
304304 ${backendName} = addBuildDepend super.${backendName} self.obelisk-run;
305305 };
306306 totalOverrides = composeExtensions (composeExtensions defaultHaskellOverrides projectOverrides) overrides;
307+ inherit (nixpkgs) lib;
308+ inherit (lib.strings) hasPrefix;
309+ privateConfigDirs = ["config/backend"];
310+ injectableConfig = builtins.filterSource (path: _:
311+ !(lib.lists.any (x: hasPrefix (toString base + "/" + toString x) (toString path)) privateConfigDirs)
312+ ) configPath;
307313 in {
308314 inherit shellToolOverrides tools withHoogle;
309315 overrides = totalOverrides;
@@ -322,19 +328,20 @@ rec {
322328 android = {
323329 ${if android == null then null else frontendName} = {
324330 executableName = "frontend";
325− ${if builtins.pathExists staticPath then "assets" else null} = assets.symlinked;
331+ ${if builtins.pathExists staticPath then "assets" else null} =
332+ executableConfig.platforms.android.inject injectableConfig processedStatic.symlinked;
326333 } // android;
327334 };
328335 ios = {
329336 ${if ios == null then null else frontendName} = {
330337 executableName = "frontend";
331− ${if builtins.pathExists staticPath then "staticSrc" else null} = assets.symlinked;
338+ ${if builtins.pathExists staticPath then "staticSrc" else null} =
339+ executableConfig.platforms.ios.inject injectableConfig processedStatic.symlinked;
332340 } // ios;
333341 };
334342 };
335343 in mkProject (projectDefinition args));
336− serverOn = sys:
337− serverExe (projectOut sys).ghc.backend (projectOut system).ghcjs.frontend assets.symlinked configPath;
344+ serverOn = sys: serverExe (projectOut sys).ghc.backend (projectOut system).ghcjs.frontend static configPath;
338345 linuxExe = serverOn "x86_64-linux";
339346 in projectOut system // {
340347 inherit linuxExe;
lib/executable-config/lookup/src-android/Obelisk/ExecutableConfig.hs+1−1
@@ -15,7 +15,7 @@ get :: Text -> IO (Maybe Text)
1515get name = bracket getAssets freeAssetManager $ \mgrObj -> do
1616 mgr <- assetManagerFromJava mgrObj
1717 let open = do
18− a <- withCString ("config" </> T.unpack name) $ \fn ->
18+ a <- withCString (T.unpack name) $ \fn ->
1919 assetManager_open mgr fn 3
2020 return $ if unAAsset a == nullPtr
2121 then Nothing
lib/executable-config/lookup/src-ios/Obelisk/ExecutableConfig.hs+1−1
@@ -14,7 +14,7 @@ import System.IO.Error
1414
1515get :: Text -> IO (Maybe Text)
1616get name = fmap join $ mainBundleResourcePath >>= \mp -> forM mp $ \p ->
17− catchDoesNotExist $ T.readFile $ T.unpack (T.decodeUtf8 p) </> "config" </> T.unpack name
17+ catchDoesNotExist $ T.readFile $ T.unpack (T.decodeUtf8 p) </> T.unpack name
1818
1919catchDoesNotExist :: IO a -> IO (Maybe a)
2020catchDoesNotExist f = catchJust doesNotExist (Just <$> f) $ const $ return Nothing
release.nix+28−27
@@ -1,12 +1,12 @@
1−{ self ? import ./. {}
2−, pkgs ? self.nixpkgs
1+{ local-self ? import ./. {}
2+, local-pkgs ? local-self.nixpkgs
33}:
44
5−with pkgs;
5+with local-pkgs.lib;
66
7−{
8− inherit (self) command;
9− built-skeleton = (import ./skeleton {}).all;
7+genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system: {
8+ inherit (import ./. { inherit system; }) command;
9+ built-skeleton = (import ./skeleton { inherit system; }).all;
1010 tests = {
1111 #TODO: Doesn't work; see discussion in https://www.pivotaltracker.com/story/show/157265140
1212 # ob-init = runCommand "ob-init" {
@@ -20,25 +20,26 @@ with pkgs;
2020 # # ob init --symlink=${self.path}
2121 #'';
2222
23− verify-migration = runCommand "verify-migration" {
24− nativeBuildInputs = [
25− self.command
26− nix # obelisk uses `nix-hash`
27− ];
28− } ''
29− set -e
30− # Fix permissions so `removePathForcibly` works on copied-to-tmp paths
31− cp -a ${self.pathGit} $TMPDIR/obelisk
32− cd $TMPDIR/obelisk
33− chmod -R u+w .
34−
35− (set -x;
36− ob internal hash;
37− ob internal verify-migration;
38− )
39−
40− mkdir -p $out
41− touch $out/done
42− '';
23+ #TODO: Re-enable this
24+ #verify-migration = runCommand "verify-migration" {
25+ # nativeBuildInputs = [
26+ # self.command
27+ # nix # obelisk uses `nix-hash`
28+ # ];
29+ #} ''
30+ # set -e
31+ # # Fix permissions so `removePathForcibly` works on copied-to-tmp paths
32+ # cp -a ${self.pathGit} $TMPDIR/obelisk
33+ # cd $TMPDIR/obelisk
34+ # chmod -R u+w .
35+ #
36+ # (set -x;
37+ # ob internal hash;
38+ # ob internal verify-migration;
39+ # )
40+ #
41+ # mkdir -p $out
42+ # touch $out/done
43+ #'';
4344 };
44−}
45+})