diff --git a/src/global/Configs.cpp b/src/global/Configs.cpp index e7bec9c..f0dfe53 100644 --- a/src/global/Configs.cpp +++ b/src/global/Configs.cpp @@ -404,6 +404,12 @@ namespace Configs { // System Utils QString FindCoreRealPath() { + // find in PATH first + QString path_for_nixos = QStandardPaths::findExecutable("throne-core"); + if (!path_for_nixos.isEmpty()) { + return path_for_nixos; + } + auto fn = QApplication::applicationDirPath() + "/Core"; #ifdef Q_OS_WIN fn += ".exe"; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index d31c311..ce4c357 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -151,8 +151,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi Configs::dataStore->core_port = MkPort(); if (Configs::dataStore->core_port <= 0) Configs::dataStore->core_port = 19810; - auto core_path = QApplication::applicationDirPath() + "/"; - core_path += "Core"; + auto core_path = Configs::FindCoreRealPath(); QStringList args; args.push_back("-port"); @@ -1045,6 +1044,15 @@ bool MainWindow::get_elevated_permissions(int reason) { return true; } if (Configs::IsAdmin()) return true; + QMessageBox::critical( + GetMessageBoxParent(), + tr("Unable to elevate privileges when installed with Nix"), + tr("Due to the read-only property of Nix store, we cannot set suid for throne-core. If you are using NixOS, please set `programs.throne.tunMode.enable` option to elevate privileges."), + QMessageBox::Ok + ); + return false; + // The following code isn't effective, preserve to avoid merge conflict + #ifdef Q_OS_LINUX if (!Linux_HavePkexec()) { MessageBoxWarning(software_name, "Please install \"pkexec\" first.");