Skip to content

Commit a9cedf6

Browse files
author
Jason Mobarak
authored
feat: enable running on NixOS (#1166)
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 ```
1 parent 661bb03 commit a9cedf6

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

resources/SolutionTab.qml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ MainTab {
5757
SolutionTabComponents.SolutionVelocityTab {
5858
}
5959

60-
SolutionTabComponents.SolutionMapTab {
60+
Rectangle {
61+
width: parent.width
62+
height: parent.height
63+
Loader {
64+
sourceComponent: Globals.enableMap ? solutionMap : null
65+
}
66+
}
67+
68+
property Component solutionMap: SolutionTabComponents.SolutionMapTab {
6169
}
6270
}
6371
}

shell.nix

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
(pkgs.buildFHSUserEnv {
4+
name = "swift-toolbox";
5+
targetPkgs = pkgs: (with pkgs;
6+
[ imagemagick
7+
libxcrypt-legacy
8+
glib
9+
capnproto
10+
openssl
11+
pkg-config
12+
cmake
13+
clang
14+
libglvnd
15+
libxkbcommon
16+
nss
17+
nspr
18+
wayland
19+
fontconfig
20+
freetype
21+
expat
22+
alsa-lib
23+
dbus
24+
libkrb5
25+
zlib
26+
gdb
27+
]) ++ (with pkgs.xorg;
28+
[ libX11
29+
libXcursor
30+
libXrandr
31+
libxkbfile
32+
libXcomposite
33+
libXdamage
34+
libXext
35+
libXfixes
36+
libXrender
37+
libXtst
38+
libxcb
39+
xcbutilkeysyms
40+
xcbutilimage
41+
xcbutilwm
42+
xcbutilrenderutil
43+
libXi
44+
libxshmfence
45+
]);
46+
profile = ''
47+
unset QT_QPA_PLATFORMTHEME
48+
unset QT_STYLE_OVERRIDE
49+
unset QTWEBKIT_PLUGIN_PATH
50+
unset QT_PLUGIN_PATH
51+
52+
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig"
53+
export LIBCLANG_PATH="${pkgs.llvmPackages_11.libclang.lib}/lib"
54+
'';
55+
runScript = "bash";
56+
}).env

swiftnav_console/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@
148148
settings_rows_to_dict,
149149
)
150150

151-
from .solution_map import SolutionMap
152-
153151
from .solution_position_tab import (
154152
SolutionPositionModel,
155153
SolutionPositionPoints,
@@ -261,6 +259,7 @@
261259
capnp.remove_import_hook() # pylint: disable=no-member
262260

263261
MAP_ENABLED = [False]
262+
SolutionMap = QObject
264263

265264

266265
class BackendMessageReceiver(QObject): # pylint: disable=too-many-instance-attributes
@@ -493,12 +492,10 @@ def _process_message_buffer(self, buffer):
493492
up = m.statusBarStatus.ntripUpload
494493
down = m.statusBarStatus.ntripDownload
495494
down_units = "B/s"
496-
497495
if down >= 1000:
498496
down /= 1000
499497
down = round(down, 1)
500498
down_units = "KB/s"
501-
502499
connected = m.statusBarStatus.ntripConnected
503500
if connected:
504501
data[Keys.NTRIP_DISPLAY] = f"{up}B/s ⬆ {down}{down_units} ⬇"
@@ -798,6 +795,12 @@ def main(passed_args: Optional[Tuple[str, ...]] = None) -> int:
798795
QQuickStyle.setStyle("Material")
799796
# We specifically *don't* want the RobotoCondensed-Bold.ttf font so we get the right look when bolded.
800797

798+
if MAP_ENABLED[0]:
799+
global SolutionMap # pylint: disable=global-statement
800+
from .solution_map import SolutionMap as SolutionMap_ # pylint: disable=import-outside-toplevel
801+
802+
SolutionMap = SolutionMap_ # type: ignore
803+
801804
qmlRegisterType(ConnectionData, "SwiftConsole", 1, 0, "ConnectionData") # type: ignore
802805
qmlRegisterType(AdvancedImuPoints, "SwiftConsole", 1, 0, "AdvancedImuPoints") # type: ignore
803806
qmlRegisterType(AdvancedMagnetometerPoints, "SwiftConsole", 1, 0, "AdvancedMagnetometerPoints") # type: ignore

0 commit comments

Comments
 (0)