Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nix] patch realm as a nodePackage use it from nix store, add to default nix-shell buildDependencies #7759

Merged
merged 2 commits into from May 23, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -2,6 +2,6 @@ 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;
node;10.15.0;
StatusImAppImage;20181208;
StatusIm-Windows-base-image;20181113;
@@ -140,11 +140,11 @@ desktop-server:
# -------------
_run-%:
$(eval SYSTEM := $(word 2, $(subst -, , $@)))
react-native run-$(SYSTEM)
npx react-native run-$(SYSTEM)

run-android: export TARGET_OS ?= android
run-android: ##@run Run Android build
react-native run-android --appIdSuffix debug
npx react-native run-android --appIdSuffix debug

run-desktop: export TARGET_OS ?= $(HOST_OS)
run-desktop: _run-desktop ##@run Run Desktop build
@@ -153,9 +153,9 @@ SIMULATOR=
run-ios: export TARGET_OS ?= ios
run-ios: ##@run Run iOS build
ifneq ("$(SIMULATOR)", "")
react-native run-ios --simulator="$(SIMULATOR)"
npx react-native run-ios --simulator="$(SIMULATOR)"
else
react-native run-ios
npx react-native run-ios
endif

#--------------
@@ -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; 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/output {
# 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;
@@ -29,12 +29,12 @@ let
--replace "\"\$QTKEYCHAIN_VERSION" qtkeychain
'';

meta = {
meta = with stdenv.lib; {
description = "Patched sources for qtkeychain, a platform-independent Qt API for storing passwords securely";
homepage = https://github.com/status-im/qtkeychain;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = with stdenv.lib.platforms; darwin ++ linux;
license = licenses.bsd3;
maintainers = [ maintainers.pombeirp ];
platforms = with platforms; darwin ++ linux;
};
};

@@ -1,6 +1,6 @@
{ stdenv, callPackage, target-os,
{ stdenv, pkgs, callPackage, target-os,
cmake, extra-cmake-modules, file, status-go,
darwin }:
darwin, nodejs }:

with stdenv;

@@ -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
{
@@ -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 ]));
}
@@ -1,6 +1,4 @@
{ pkgs, stdenv, fetchurl }:

with pkgs;
{ stdenv, fetchurl, unzip }:

let
package = stdenv.mkDerivation rec {
@@ -23,12 +21,12 @@ let
unzip $src -d $out/src
'';

meta = {
meta = with stdenv.lib; {
description = "A base image for Linux Status Desktop release distributions";
homepage = https://desktop-app-files.ams3.digitaloceanspaces.com/;
license = stdenv.lib.licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = stdenv.lib.platforms.linux;
license = licenses.gpl3;
maintainers = [ maintainers.pombeirp ];
platforms = platforms.linux;
};
};

@@ -1,9 +1,7 @@
{ pkgs, stdenv, fetchurl }:

with pkgs;
{ stdenv, fetchurl, unzip }:

let
package = stdenv.mkDerivation rec {
package = stdenv.mkDerivation rec {
name = "StatusImAppBundle";
version = "20190515";

@@ -23,12 +21,12 @@ let
unzip $src -d $out/src
'';

meta = {
meta = with stdenv.lib; {
description = "A base image for macOS Status Desktop release distributions";
homepage = https://desktop-app-files.ams3.digitaloceanspaces.com/;
license = stdenv.lib.licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.pombeirp ];
platforms = stdenv.lib.platforms.darwin;
license = licenses.gpl3;
maintainers = [ maintainers.pombeirp ];
platforms = platforms.darwin;
};
};

File renamed without changes.
@@ -0,0 +1,35 @@
{ pkgs, nodejs }:

#
# This expression builds the realm executable that is used for debugging the desktop app (used by ubuntu-server.js)
#

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";
# We download ${realm-core-src} to ${realm-dest-dir} in order to avoid having realm try to download these files on its own (which is disallowed by Nix)
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}
'';
});
}
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

#
# Run this file to regenerate the Nix files in ./output.
# Prerequisites: Node, npm, and node2nix (installed with npm i -g https://github.com/svanderburg/node2nix)
#

GIT_ROOT=$(git rev-parse --show-toplevel)
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
toolversion="${GIT_ROOT}/scripts/toolversion"
@@ -8,16 +13,18 @@ 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)
# Specify the package.json file containing the dependencies to install
cat << EOF > $input
[
{ "react-native-cli": "${react_native_cli_required_version}" }
{ "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} --bypass-cache -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
@@ -1,4 +1,4 @@
# This file has been generated by node2nix 1.6.0. Do not edit!
# This file has been generated by node2nix 1.6.1. Do not edit!

{pkgs ? import <nixpkgs> {
inherit system;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.