Skip to content

Commit

Permalink
Split into desktop and mobile versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Pombeiro committed May 22, 2019
1 parent dd4093b commit e89c611
Show file tree
Hide file tree
Showing 17 changed files with 2,642 additions and 348 deletions.
1 change: 0 additions & 1 deletion .TOOLVERSIONS
Expand Up @@ -2,6 +2,5 @@ android-sdk-build-tools;28.0.1;
android-sdk-platform;android-27;
android-sdk;4333796;aa190cfd7299cd6a1c687355bb2764e4
nix;2.2.1;
react_native_cli;2.0.1;
StatusImAppImage;20181208;
StatusIm-Windows-base-image;20181113;
11 changes: 3 additions & 8 deletions derivation.nix
Expand Up @@ -8,21 +8,16 @@ let
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
stdenv' = pkgs.stdenvNoCC;
gradle = pkgs.gradle_4_10;
statusDesktop = pkgs.callPackage ./nix/desktop { inherit target-os status-go; inherit (pkgs) darwin; nodejs = nodejs'; stdenv = stdenv'; };
statusMobile = pkgs.callPackage ./nix/mobile { inherit target-os config status-go gradle; inherit (pkgs.xcodeenv) composeXcodeWrapper; stdenv = stdenv'; };
statusDesktop = pkgs.callPackage ./nix/desktop { inherit target-os status-go pkgs; inherit (pkgs) darwin; stdenv = stdenv'; nodejs = nodejs'; };
statusMobile = pkgs.callPackage ./nix/mobile { inherit target-os config pkgs status-go gradle; inherit (pkgs.xcodeenv) composeXcodeWrapper; stdenv = stdenv'; nodejs = nodejs'; };
status-go = pkgs.callPackage ./nix/status-go { inherit target-os; inherit (pkgs.xcodeenv) composeXcodeWrapper; inherit (statusMobile) xcodewrapperArgs; androidPkgs = statusMobile.androidComposition; };
nodejs' = pkgs.nodejs-10_x;
yarn' = pkgs.yarn.override { nodejs = nodejs'; };
nodeInputs = import ./nix/global-node-packages {
# The remaining dependencies come from Nixpkgs
inherit pkgs;
nodejs = nodejs';
};
nodePkgBuildInputs = [
nodejs'
pkgs.python27 # for e.g. gyp
yarn'
] ++ (builtins.attrValues nodeInputs);
];
selectedSources =
stdenv'.lib.optional platform.targetDesktop statusDesktop ++
stdenv'.lib.optional platform.targetMobile statusMobile;
Expand Down
10 changes: 8 additions & 2 deletions nix/desktop/default.nix
@@ -1,4 +1,4 @@
{ stdenv, callPackage, target-os,
{ stdenv, pkgs, callPackage, target-os,
cmake, extra-cmake-modules, file, status-go,
darwin, nodejs }:

Expand All @@ -15,6 +15,10 @@ let
lib.optional platform.targetLinux linuxPlatform ++
lib.optional platform.targetDarwin darwinPlatform ++
lib.optional platform.targetWindows windowsPlatform;
nodeInputs = import ./realm-node {
# The remaining dependencies come from Nixpkgs
inherit pkgs nodejs;
};

in
{
Expand All @@ -24,6 +28,8 @@ in
file
snoreNotifySources
qtkeychainSources
] ++ lib.catAttrs "buildInputs" selectedSources;
] ++ lib.catAttrs "buildInputs" selectedSources ++
(builtins.attrValues nodeInputs);

shellHook = lib.concatStrings (lib.catAttrs "shellHook" (selectedSources ++ [ snoreNotifySources qtkeychainSources ]));
}
File renamed without changes.
30 changes: 30 additions & 0 deletions nix/desktop/realm-node/default.nix
@@ -0,0 +1,30 @@
{ pkgs, nodejs }:

let nodePackages = import ./output { inherit pkgs nodejs; };
realm-version = "5.12.1";
realm-patched-name = "realm-https://github.com/status-im/realm-js/archive/v2.20.1.tar.gz";
realm-core-src = pkgs.fetchurl (
if builtins.currentSystem == "x86_64-darwin" then {
url = "https://static.realm.io/downloads/core/realm-core-Release-v${realm-version}-Darwin-devel.tar.gz";
sha256 = "05ji1zyskwjj8p5i01kcg7h1cxdjj62fcsp6haf2f65qshp6r44d";
} else {
url = "https://static.realm.io/downloads/core/realm-core-Release-v${realm-version}-Linux-devel.tar.gz";
sha256 = "02pvi28qnvzdv7ghqzf79bxn8id9s7mpp3g2ambxg8jrcrkqfvr1";
}
);
realm-dest-dir = if builtins.currentSystem == "x86_64-darwin" then
"$out/lib/node_modules/realm/compiled/node-v64_darwin_x64/realm.node" else
"$out/lib/node_modules/realm/compiled/node-v64_linux_x64/realm.node";
in nodePackages // {
${realm-patched-name} = nodePackages.${realm-patched-name}.override(oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [ pkgs.nodePackages.node-pre-gyp ];
reconstructLock = true;
preRebuild = ''
# Do not attempt to do any http calls!
substituteInPlace $out/lib/node_modules/realm/scripts/download-realm.js \
--replace "!shouldSkipAcquire(realmDir, requirements, options.force)" "false"
mkdir -p ${realm-dest-dir}
tar -xzf ${realm-core-src} -C ${realm-dest-dir}
'';
});
}
Expand Up @@ -8,18 +8,16 @@ input="${dir}/output/node-packages.json"
output_dir="${dir}/output"

rm -rf $output_dir && mkdir -p $output_dir
react_native_cli_required_version=$($toolversion react_native_cli)
cat << EOF > $input
[
{ "react-native-cli": "${react_native_cli_required_version}",
"realm": "git+https://github.com/status-im/realm-js.git#heads/v2.20.1" }
{ "realm": "https://github.com/status-im/realm-js/archive/v2.20.1.tar.gz" }
]
EOF

node_required_version=$($toolversion node)
node_major_version=$(echo $node_required_version | cut -d. -f1,1)

node2nix --nodejs-${node_major_version} -i $input \
node2nix --nodejs-${node_major_version} --bypass-cache -i $input \
-o $output_dir/node-packages.nix \
-c $output_dir/default.nix \
-e $output_dir/node-env.nix
Expand Down
Expand Up @@ -2,7 +2,7 @@

{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-10_x"}:
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-6_x"}:

let
nodeEnv = import ./node-env.nix {
Expand Down
File renamed without changes.

0 comments on commit e89c611

Please sign in to comment.