Minor refactoring of the way dependency packages are iterated for shellHook and buildInputs.

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-05-13 11:22:29 +02:00
parent 90d517adf6
commit b542c7de26
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
7 changed files with 50 additions and 50 deletions

View File

@ -23,6 +23,9 @@ with pkgs;
python27 # for e.g. gyp python27 # for e.g. gyp
yarn' yarn'
] ++ (builtins.attrValues nodeInputs); ] ++ (builtins.attrValues nodeInputs);
selectedSources =
lib.optional platform.targetDesktop statusDesktop ++
lib.optional platform.targetMobile statusMobile;
in _stdenv.mkDerivation rec { in _stdenv.mkDerivation rec {
name = "status-react-build-env"; name = "status-react-build-env";
@ -36,9 +39,6 @@ with pkgs;
++ lib.optional isDarwin cocoapods ++ lib.optional isDarwin cocoapods
++ lib.optional (isDarwin && !platform.targetIOS) clang ++ lib.optional (isDarwin && !platform.targetIOS) clang
++ lib.optional (!isDarwin) gcc7 ++ lib.optional (!isDarwin) gcc7
++ lib.optionals platform.targetDesktop statusDesktop.buildInputs ++ lib.catAttrs "buildInputs" selectedSources;
++ lib.optionals platform.targetMobile statusMobile.buildInputs; shellHook = lib.concatStrings (lib.catAttrs "shellHook" selectedSources);
shellHook =
lib.optionalString platform.targetDesktop statusDesktop.shellHook +
lib.optionalString platform.targetMobile statusMobile.shellHook;
} }

View File

@ -10,6 +10,10 @@ let
windowsPlatform = callPackage ./windows { }; windowsPlatform = callPackage ./windows { };
snoreNotifySources = callPackage ./cmake/snorenotify { }; snoreNotifySources = callPackage ./cmake/snorenotify { };
qtkeychainSources = callPackage ./cmake/qtkeychain { }; qtkeychainSources = callPackage ./cmake/qtkeychain { };
selectedSources =
lib.optional platform.targetLinux linuxPlatform ++
lib.optional platform.targetDarwin darwinPlatform ++
lib.optional platform.targetWindows windowsPlatform;
in in
{ {
@ -19,19 +23,6 @@ in
file file
snoreNotifySources snoreNotifySources
qtkeychainSources qtkeychainSources
] ++ lib.optionals platform.targetLinux linuxPlatform.buildInputs ] ++ lib.catAttrs "buildInputs" selectedSources;
++ lib.optionals platform.targetDarwin darwinPlatform.buildInputs shellHook = lib.concatStrings (lib.catAttrs "shellHook" (selectedSources ++ [ snoreNotifySources qtkeychainSources ]));
++ lib.optionals platform.targetWindows windowsPlatform.buildInputs
++ lib.optional (! platform.targetWindows) qt5.full;
shellHook =
snoreNotifySources.shellHook +
qtkeychainSources.shellHook +
lib.optionalString (target-os != "windows") ''
export QT_PATH="${qt5.full}"
export QT_BASEBIN_PATH="${qt5.qtbase.bin}"
export PATH="${qt5.full}/bin:$PATH"
'' +
lib.optionalString platform.targetLinux linuxPlatform.shellHook +
lib.optionalString platform.targetDarwin darwinPlatform.shellHook +
lib.optionalString platform.targetWindows windowsPlatform.shellHook;
} }

View File

@ -16,9 +16,14 @@ in {
linuxdeployqt linuxdeployqt
patchelf patchelf
baseImage baseImage
] ++ status-go.packages; qt5.full
] ++ status-go.buildInputs;
shellHook = shellHook =
baseImage.shellHook + baseImage.shellHook +
status-go.shellHook; status-go.shellHook + ''
export QT_PATH="${qt5.full}"
export QT_BASEBIN_PATH="${qt5.qtbase.bin}"
export PATH="${qt5.full}/bin:$PATH"
'';
} }

View File

@ -12,7 +12,8 @@ let
in in
{ {
buildInputs = [ buildInputs = [
baseImage status-go.packages baseImage status-go.buildInputs
qt5.full
AppKit Cocoa darwin.cf-private Foundation OpenGL AppKit Cocoa darwin.cf-private Foundation OpenGL
]; ];
@ -20,5 +21,8 @@ in
baseImage.shellHook + baseImage.shellHook +
status-go.shellHook + '' status-go.shellHook + ''
export NIX_TARGET_LDFLAGS="-F${CoreFoundation}/Library/Frameworks -framework CoreFoundation $NIX_TARGET_LDFLAGS" export NIX_TARGET_LDFLAGS="-F${CoreFoundation}/Library/Frameworks -framework CoreFoundation $NIX_TARGET_LDFLAGS"
export QT_PATH="${qt5.full}"
export QT_BASEBIN_PATH="${qt5.qtbase.bin}"
export PATH="${qt5.full}/bin:$PATH"
''; '';
} }

View File

@ -1,4 +1,4 @@
{ config, stdenv, pkgs, target-os ? "all", status-go }: { config, stdenv, pkgs, target-os, status-go }:
with pkgs; with pkgs;
with stdenv; with stdenv;
@ -10,18 +10,19 @@ let
version = "10.1"; version = "10.1";
}; };
xcodeWrapper = xcodeenv.composeXcodeWrapper xcodewrapperArgs; xcodeWrapper = xcodeenv.composeXcodeWrapper xcodewrapperArgs;
android = callPackage ./android.nix { inherit config; }; androidPlatform = callPackage ./android.nix { inherit config; };
selectedSources =
[ status-go ] ++
lib.optional platform.targetAndroid androidPlatform;
in in
{ {
inherit (android) androidComposition; inherit (androidPlatform) androidComposition;
inherit xcodewrapperArgs; inherit xcodewrapperArgs;
buildInputs = buildInputs =
status-go.packages ++ status-go.buildInputs ++
lib.optionals platform.targetAndroid android.buildInputs ++ lib.catAttrs "buildInputs" selectedSources ++
lib.optional (platform.targetIOS && isDarwin) xcodeWrapper; lib.optional (platform.targetIOS && isDarwin) xcodeWrapper;
shellHook = shellHook = lib.concatStrings (lib.catAttrs "shellHook" selectedSources);
status-go.shellHook +
lib.optionalString platform.targetAndroid android.shellHook;
} }

View File

@ -71,14 +71,14 @@ let
}); });
}; };
packages = if target-os == "android" then [ status-go-packages.android ] else buildInputs = if target-os == "android" then [ status-go-packages.android ] else
if target-os == "ios" then [ status-go-packages.ios ] else if target-os == "ios" then [ status-go-packages.ios ] else
if target-os == "all" then currentHostConfig.allTargets else if target-os == "all" then currentHostConfig.allTargets else
if platform.targetDesktop then [ status-go-packages.desktop ] else if platform.targetDesktop then [ status-go-packages.desktop ] else
throw "Unexpected target platform ${target-os}"; throw "Unexpected target platform ${target-os}";
in { in {
inherit packages; inherit buildInputs;
shellHook = shellHook =
lib.optionalString platform.targetIOS '' lib.optionalString platform.targetIOS ''

View File

@ -33,20 +33,19 @@ in mkShell' {
] ++ ] ++
(if useFastlanePkg then [ fastlane' ] else lib.optionals platform.targetMobile [ bundler ruby ]); # bundler/ruby used for fastlane on macOS (if useFastlanePkg then [ fastlane' ] else lib.optionals platform.targetMobile [ bundler ruby ]); # bundler/ruby used for fastlane on macOS
inputsFrom = [ projectDeps ]; inputsFrom = [ projectDeps ];
TARGET_OS=target-os; TARGET_OS = target-os;
shellHook = shellHook = ''
'' set -e
set -e
STATUS_REACT_HOME=$(git rev-parse --show-toplevel) STATUS_REACT_HOME=$(git rev-parse --show-toplevel)
${projectDeps.shellHook} ${projectDeps.shellHook}
${lib.optionalString useFastlanePkg fastlane'.shellHook} ${lib.optionalString useFastlanePkg fastlane'.shellHook}
if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then
$STATUS_REACT_HOME/scripts/setup $STATUS_REACT_HOME/scripts/setup
touch $STATUS_REACT_HOME/.ran-setup touch $STATUS_REACT_HOME/.ran-setup
fi fi
set +e set +e
''; '';
} }