Skip to content

Commit

Permalink
feat: enable running on NixOS (#1166)
Browse files Browse the repository at this point in the history
Allows the console be built and run on NixOS. I could not get the
WebView to work and attempting to load it would cause the process to
crash, so additional work was needed to avoid loading it altogether.

Basic usage on NixOS:

```
nix-shell
cargo make run
```
  • Loading branch information
Jason Mobarak authored Aug 31, 2023
1 parent 661bb03 commit a9cedf6
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
10 changes: 9 additions & 1 deletion resources/SolutionTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ MainTab {
SolutionTabComponents.SolutionVelocityTab {
}

SolutionTabComponents.SolutionMapTab {
Rectangle {
width: parent.width
height: parent.height
Loader {
sourceComponent: Globals.enableMap ? solutionMap : null
}
}

property Component solutionMap: SolutionTabComponents.SolutionMapTab {
}
}
}
Expand Down
56 changes: 56 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSUserEnv {
name = "swift-toolbox";
targetPkgs = pkgs: (with pkgs;
[ imagemagick
libxcrypt-legacy
glib
capnproto
openssl
pkg-config
cmake
clang
libglvnd
libxkbcommon
nss
nspr
wayland
fontconfig
freetype
expat
alsa-lib
dbus
libkrb5
zlib
gdb
]) ++ (with pkgs.xorg;
[ libX11
libXcursor
libXrandr
libxkbfile
libXcomposite
libXdamage
libXext
libXfixes
libXrender
libXtst
libxcb
xcbutilkeysyms
xcbutilimage
xcbutilwm
xcbutilrenderutil
libXi
libxshmfence
]);
profile = ''
unset QT_QPA_PLATFORMTHEME
unset QT_STYLE_OVERRIDE
unset QTWEBKIT_PLUGIN_PATH
unset QT_PLUGIN_PATH
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig"
export LIBCLANG_PATH="${pkgs.llvmPackages_11.libclang.lib}/lib"
'';
runScript = "bash";
}).env
11 changes: 7 additions & 4 deletions swiftnav_console/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
settings_rows_to_dict,
)

from .solution_map import SolutionMap

from .solution_position_tab import (
SolutionPositionModel,
SolutionPositionPoints,
Expand Down Expand Up @@ -261,6 +259,7 @@
capnp.remove_import_hook() # pylint: disable=no-member

MAP_ENABLED = [False]
SolutionMap = QObject


class BackendMessageReceiver(QObject): # pylint: disable=too-many-instance-attributes
Expand Down Expand Up @@ -493,12 +492,10 @@ def _process_message_buffer(self, buffer):
up = m.statusBarStatus.ntripUpload
down = m.statusBarStatus.ntripDownload
down_units = "B/s"

if down >= 1000:
down /= 1000
down = round(down, 1)
down_units = "KB/s"

connected = m.statusBarStatus.ntripConnected
if connected:
data[Keys.NTRIP_DISPLAY] = f"{up}B/s ⬆ {down}{down_units} ⬇"
Expand Down Expand Up @@ -798,6 +795,12 @@ def main(passed_args: Optional[Tuple[str, ...]] = None) -> int:
QQuickStyle.setStyle("Material")
# We specifically *don't* want the RobotoCondensed-Bold.ttf font so we get the right look when bolded.

if MAP_ENABLED[0]:
global SolutionMap # pylint: disable=global-statement
from .solution_map import SolutionMap as SolutionMap_ # pylint: disable=import-outside-toplevel

SolutionMap = SolutionMap_ # type: ignore

qmlRegisterType(ConnectionData, "SwiftConsole", 1, 0, "ConnectionData") # type: ignore
qmlRegisterType(AdvancedImuPoints, "SwiftConsole", 1, 0, "AdvancedImuPoints") # type: ignore
qmlRegisterType(AdvancedMagnetometerPoints, "SwiftConsole", 1, 0, "AdvancedMagnetometerPoints") # type: ignore
Expand Down

0 comments on commit a9cedf6

Please sign in to comment.