Skip to content

Commit

Permalink
Remove usages of nix show-derivation in build-desktop.sh for purity
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Pombeiro committed Apr 8, 2019
1 parent beae40c commit edc36b3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
6 changes: 5 additions & 1 deletion nix/desktop/default.nix
Expand Up @@ -34,6 +34,10 @@ in
unset QT_PATH
'' else ''
export QT_PATH="${qt5.full}"
export QT_BASEBIN_PATH="${qt5.qtbase.bin}"
export PATH="${stdenv.lib.makeBinPath [ qt5.full ]}:$PATH"
'');
'') +
lib.optionalString targetLinux linuxPlatform.shellHook +
lib.optionalString targetDarwin darwinPlatform.shellHook +
lib.optionalString targetWindows windowsPlatform.shellHook;
}
4 changes: 4 additions & 0 deletions nix/desktop/linux/default.nix
Expand Up @@ -11,4 +11,8 @@ let
in
{
buildInputs = [ appimagekit linuxdeployqt patchelf baseImage ];

shellHook = ''
export STATUSREACT_LINUX_BASEIMAGE_PATH="${baseImage}/src"
'';
}
4 changes: 4 additions & 0 deletions nix/desktop/macos/default.nix
Expand Up @@ -9,4 +9,8 @@ let
in
{
buildInputs = [ baseImage ];

shellHook = ''
export STATUSREACT_MACOS_BASEIMAGE_PATH="${baseImage}/src"
'';
}
4 changes: 4 additions & 0 deletions nix/desktop/windows/default.nix
Expand Up @@ -14,4 +14,8 @@ in
baseImage
go # Needed for Windows build only
];

shellHook = ''
export STATUSREACT_WINDOWS_BASEIMAGE_PATH="${baseImage}/src"
'';
}
29 changes: 5 additions & 24 deletions scripts/build-desktop.sh
Expand Up @@ -209,14 +209,12 @@ function bundleWindows() {
fi

# TODO this needs to be fixed: status-react/issues/5378
local windowsBaseImagePath="$(nix show-derivation -r -f $STATUSREACTPATH | jq -r '.[] | select(.env.name=="StatusIm-Windows-base-image") | .outputs.out.path')/src/"

local top_srcdir=$(joinExistingPath "$STATUSREACTPATH" '.')
VERSION_MAJOR="$(cut -d'.' -f1 <<<"$VERSION")"
VERSION_MINOR="$(cut -d'.' -f2 <<<"$VERSION")"
VERSION_BUILD="$(cut -d'.' -f3 <<<"$VERSION")"
makensis -Dtop_srcdir=${top_srcdir} \
-Dbase_image_dir=${windowsBaseImagePath} \
-Dbase_image_dir=${STATUSREACT_WINDOWS_BASEIMAGE_PATH} \
-DCOMPRESSION_ALGO=${compressionAlgo} \
-DCOMPRESSION_TYPE=${compressionType} \
-DVERSION_MAJOR=$VERSION_MAJOR \
Expand All @@ -239,8 +237,7 @@ function bundleLinux() {
rm -rf StatusImAppImage AppDir

# TODO this needs to be fixed: status-react/issues/5378
local baseAppImagePath="$(nix show-derivation -r -f $STATUSREACTPATH | jq -r '.[] | select(.env.name=="StatusImAppImage") | .outputs.out.path')/src"
cp -r $baseAppImagePath/StatusImAppImage .
cp -r ${STATUSREACT_LINUX_BASEIMAGE_PATH}/StatusImAppImage .
chmod -R +w StatusImAppImage/

mkdir AppDir
Expand Down Expand Up @@ -305,19 +302,6 @@ function bundleLinux() {
}

if is_macos; then
function getQtFullOutPathFromNixStore() {
local qtFullDerivationPath=$(nix show-derivation -f $STATUSREACTPATH/default.nix | jq -r '.[] | .inputDrvs | 'keys' | .[]' | grep qt-full)

echo $(nix show-derivation $qtFullDerivationPath | jq -r '.[] | .outputs.out.path')
}

function getQtBaseBinPathFromNixStore() {
local qtFullDerivationPath=$(nix show-derivation -f $STATUSREACTPATH/default.nix | jq -r '.[] | .inputDrvs | 'keys' | .[]' | grep qt-full)
local qtBaseDerivationPath=$(nix show-derivation $qtFullDerivationPath | jq -r '.[] | .inputDrvs | 'keys' | .[]' | grep qtbase)

echo $(nix show-derivation $qtBaseDerivationPath | jq -r '.[] | .outputs.bin.path')
}

function copyDylibNixDependenciesToPackage() {
local dylib="$1"
local contentsDir="$2"
Expand Down Expand Up @@ -444,8 +428,7 @@ function bundleMacOS() {
# download prepared package with mac bundle files (it contains qt libraries, icon)
rm -rf Status.app
# TODO this needs to be fixed: status-react/issues/5378
local baseAppImagePath="$(nix show-derivation -r -f $STATUSREACTPATH | jq -r '.[] | select(.env.name=="StatusImAppBundle") | .outputs.out.path')/src"
cp -r $baseAppImagePath/Status.app .
cp -r ${STATUSREACT_MACOS_BASEIMAGE_PATH}/Status.app .
chmod -R +w Status.app/

local contentsPath='Status.app/Contents'
Expand All @@ -468,11 +451,9 @@ function bundleMacOS() {
if program_exists nix && [ -n "$IN_NIX_SHELL" ]; then
# Since in the Nix qt.full package the different Qt modules are spread across several directories,
# macdeployqt cannot find some qtbase plugins, so we copy them in its place
local qtbaseBinPath=$(getQtBaseBinPathFromNixStore)
local qtfullOutPath=$(getQtFullOutPathFromNixStore)
mkdir -p "$contentsPath/PlugIns"
for plugin in ${qtbaseplugins[@]}; do copyQtPlugInToPackage "$qtbaseBinPath" "$plugin" "$contentsPath"; done
for plugin in ${qtfullplugins[@]}; do copyQtPlugInToPackage "$qtfullOutPath" "$plugin" "$contentsPath"; done
for plugin in ${qtbaseplugins[@]}; do copyQtPlugInToPackage "$QT_BASEBIN_PATH" "$plugin" "$contentsPath"; done
for plugin in ${qtfullplugins[@]}; do copyQtPlugInToPackage "$QT_PATH" "$plugin" "$contentsPath"; done
fi

macdeployqt Status.app \
Expand Down

0 comments on commit edc36b3

Please sign in to comment.