lez-programs/apps/amm/flake.nix
2026-07-15 18:15:01 -03:00

67 lines
2.6 KiB
Nix

{
description = "Logos AMM QML UI trade and provide liquidity on the LEZ AMM";
inputs = {
logos-module-builder.url = "github:logos-co/logos-module-builder";
# Shared C++ wallet access and Logos.Wallet QML sources.
shared_wallet = {
url = "path:../shared/wallet";
flake = false;
};
# Core wallet module. This revision submits generic public transactions by
# deployed program ID and keeps the `logos_execution_zone` module identity.
logos_execution_zone.url = "github:logos-blockchain/logos-execution-zone-module?rev=d70225ced646934d2294fd9e8f8b03615c104b80";
# A path input to the repository contains this flake.lock, which makes
# its lock hash self-referential. Pin the client to this PR's remote
# branch instead so a fresh clone can evaluate the flake reproducibly.
amm_client.url = "github:logos-blockchain/lez-programs/feat/amm-pool-creation";
};
outputs = inputs@{ logos-module-builder, shared_wallet, ... }:
logos-module-builder.lib.mkLogosQmlModule {
src = ./.;
configFile = ./metadata.json;
flakeInputs = inputs;
preConfigure = ''
cmakeFlagsArray+=("-DLOGOS_WALLET_SOURCE_DIR=${shared_wallet}")
'';
externalLibInputs = {
amm_client = {
input = inputs.amm_client;
packages.default = "amm_client";
};
};
postInstall = ''
# The builder installs the view under lib/qml after this hook. Its
# import descriptor points back to this compiled shared QML module.
test -f ${./qml}/Logos/Wallet/qmldir
walletQmlDir="shared-wallet/qml/Logos/Wallet"
if [ ! -d "$walletQmlDir" ]; then
echo "Built Logos.Wallet QML module not found"
exit 1
fi
walletQmlInstallDir="$out/lib/Logos/Wallet"
mkdir -p "$walletQmlInstallDir"
cp -r "$walletQmlDir/." "$walletQmlInstallDir/"
test -f "$walletQmlInstallDir/qmldir"
# The standalone plugin directory only copies directories below lib/.
# Ship the Rust client in one of those directories and teach the
# backend plugin to resolve it relative to its installed location.
# This is deliberately relative so both the development Nix build and
# the portable LGX package work without DYLD_LIBRARY_PATH.
if [ -f "$out/lib/libamm_client.dylib" ]; then
runtimeLibDir="$out/lib/amm_ui_runtime"
mkdir -p "$runtimeLibDir"
cp "$out/lib/libamm_client.dylib" "$runtimeLibDir/"
install_name_tool -add_rpath "@loader_path/amm_ui_runtime" \
"$out/lib/amm_ui_plugin.dylib"
fi
'';
};
}