From b542c7de2649be6e0ddb1ff76de19f3bf9cf5232 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Mon, 13 May 2019 11:22:29 +0200 Subject: [PATCH] Minor refactoring of the way dependency packages are iterated for shellHook and buildInputs. Signed-off-by: Pedro Pombeiro --- derivation.nix | 10 +++++----- nix/desktop/default.nix | 21 ++++++--------------- nix/desktop/linux/default.nix | 9 +++++++-- nix/desktop/macos/default.nix | 6 +++++- nix/mobile/default.nix | 17 +++++++++-------- nix/status-go/default.nix | 12 ++++++------ shell.nix | 25 ++++++++++++------------- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/derivation.nix b/derivation.nix index 9a60163ffd..d96aa0d304 100644 --- a/derivation.nix +++ b/derivation.nix @@ -23,6 +23,9 @@ with pkgs; python27 # for e.g. gyp yarn' ] ++ (builtins.attrValues nodeInputs); + selectedSources = + lib.optional platform.targetDesktop statusDesktop ++ + lib.optional platform.targetMobile statusMobile; in _stdenv.mkDerivation rec { name = "status-react-build-env"; @@ -36,9 +39,6 @@ with pkgs; ++ lib.optional isDarwin cocoapods ++ lib.optional (isDarwin && !platform.targetIOS) clang ++ lib.optional (!isDarwin) gcc7 - ++ lib.optionals platform.targetDesktop statusDesktop.buildInputs - ++ lib.optionals platform.targetMobile statusMobile.buildInputs; - shellHook = - lib.optionalString platform.targetDesktop statusDesktop.shellHook + - lib.optionalString platform.targetMobile statusMobile.shellHook; + ++ lib.catAttrs "buildInputs" selectedSources; + shellHook = lib.concatStrings (lib.catAttrs "shellHook" selectedSources); } diff --git a/nix/desktop/default.nix b/nix/desktop/default.nix index f6a129acbd..b1cf873c27 100644 --- a/nix/desktop/default.nix +++ b/nix/desktop/default.nix @@ -10,6 +10,10 @@ let windowsPlatform = callPackage ./windows { }; snoreNotifySources = callPackage ./cmake/snorenotify { }; qtkeychainSources = callPackage ./cmake/qtkeychain { }; + selectedSources = + lib.optional platform.targetLinux linuxPlatform ++ + lib.optional platform.targetDarwin darwinPlatform ++ + lib.optional platform.targetWindows windowsPlatform; in { @@ -19,19 +23,6 @@ in file snoreNotifySources qtkeychainSources - ] ++ lib.optionals platform.targetLinux linuxPlatform.buildInputs - ++ lib.optionals platform.targetDarwin darwinPlatform.buildInputs - ++ 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; + ] ++ lib.catAttrs "buildInputs" selectedSources; + shellHook = lib.concatStrings (lib.catAttrs "shellHook" (selectedSources ++ [ snoreNotifySources qtkeychainSources ])); } diff --git a/nix/desktop/linux/default.nix b/nix/desktop/linux/default.nix index 7cfbab05d4..61f1d65b03 100644 --- a/nix/desktop/linux/default.nix +++ b/nix/desktop/linux/default.nix @@ -16,9 +16,14 @@ in { linuxdeployqt patchelf baseImage - ] ++ status-go.packages; + qt5.full + ] ++ status-go.buildInputs; 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" + ''; } diff --git a/nix/desktop/macos/default.nix b/nix/desktop/macos/default.nix index 7739fa3618..6b127a84cf 100644 --- a/nix/desktop/macos/default.nix +++ b/nix/desktop/macos/default.nix @@ -12,7 +12,8 @@ let in { buildInputs = [ - baseImage status-go.packages + baseImage status-go.buildInputs + qt5.full AppKit Cocoa darwin.cf-private Foundation OpenGL ]; @@ -20,5 +21,8 @@ in baseImage.shellHook + status-go.shellHook + '' 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" ''; } diff --git a/nix/mobile/default.nix b/nix/mobile/default.nix index 4979ea6f69..f5515a7db7 100644 --- a/nix/mobile/default.nix +++ b/nix/mobile/default.nix @@ -1,4 +1,4 @@ -{ config, stdenv, pkgs, target-os ? "all", status-go }: +{ config, stdenv, pkgs, target-os, status-go }: with pkgs; with stdenv; @@ -10,18 +10,19 @@ let version = "10.1"; }; 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 { - inherit (android) androidComposition; + inherit (androidPlatform) androidComposition; inherit xcodewrapperArgs; buildInputs = - status-go.packages ++ - lib.optionals platform.targetAndroid android.buildInputs ++ + status-go.buildInputs ++ + lib.catAttrs "buildInputs" selectedSources ++ lib.optional (platform.targetIOS && isDarwin) xcodeWrapper; - shellHook = - status-go.shellHook + - lib.optionalString platform.targetAndroid android.shellHook; + shellHook = lib.concatStrings (lib.catAttrs "shellHook" selectedSources); } diff --git a/nix/status-go/default.nix b/nix/status-go/default.nix index 65e72af582..cfa3bb5e36 100644 --- a/nix/status-go/default.nix +++ b/nix/status-go/default.nix @@ -71,14 +71,14 @@ let }); }; - packages = if target-os == "android" then [ status-go-packages.android ] else - if target-os == "ios" then [ status-go-packages.ios ] else - if target-os == "all" then currentHostConfig.allTargets else - if platform.targetDesktop then [ status-go-packages.desktop ] else - throw "Unexpected target platform ${target-os}"; + buildInputs = if target-os == "android" then [ status-go-packages.android ] else + if target-os == "ios" then [ status-go-packages.ios ] else + if target-os == "all" then currentHostConfig.allTargets else + if platform.targetDesktop then [ status-go-packages.desktop ] else + throw "Unexpected target platform ${target-os}"; in { - inherit packages; + inherit buildInputs; shellHook = lib.optionalString platform.targetIOS '' diff --git a/shell.nix b/shell.nix index 40eb330745..2c1a644113 100644 --- a/shell.nix +++ b/shell.nix @@ -33,20 +33,19 @@ in mkShell' { ] ++ (if useFastlanePkg then [ fastlane' ] else lib.optionals platform.targetMobile [ bundler ruby ]); # bundler/ruby used for fastlane on macOS inputsFrom = [ projectDeps ]; - TARGET_OS=target-os; - shellHook = - '' - set -e + TARGET_OS = target-os; + shellHook = '' + set -e - STATUS_REACT_HOME=$(git rev-parse --show-toplevel) + STATUS_REACT_HOME=$(git rev-parse --show-toplevel) - ${projectDeps.shellHook} - ${lib.optionalString useFastlanePkg fastlane'.shellHook} + ${projectDeps.shellHook} + ${lib.optionalString useFastlanePkg fastlane'.shellHook} - if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then - $STATUS_REACT_HOME/scripts/setup - touch $STATUS_REACT_HOME/.ran-setup - fi - set +e - ''; + if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then + $STATUS_REACT_HOME/scripts/setup + touch $STATUS_REACT_HOME/.ran-setup + fi + set +e + ''; } \ No newline at end of file