aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock30
-rw-r--r--flake.nix74
-rw-r--r--launcher/CMakeLists.txt5
-rw-r--r--launcher/InstanceImportTask.cpp8
-rw-r--r--launcher/InstanceImportTask.h3
-rw-r--r--launcher/tasks/Task.h2
-rw-r--r--launcher/tasks/Task_test.cpp68
-rw-r--r--packages/nix/polymc/default.nix17
8 files changed, 130 insertions, 77 deletions
diff --git a/flake.lock b/flake.lock
index f2205416..e3c490fd 100644
--- a/flake.lock
+++ b/flake.lock
@@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
- "lastModified": 1641205782,
- "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
+ "lastModified": 1648199409,
+ "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
"owner": "edolstra",
"repo": "flake-compat",
- "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
+ "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
"type": "github"
},
"original": {
@@ -16,21 +16,6 @@
"type": "github"
}
},
- "flake-utils": {
- "locked": {
- "lastModified": 1642700792,
- "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
- "type": "github"
- },
- "original": {
- "owner": "numtide",
- "repo": "flake-utils",
- "type": "github"
- }
- },
"libnbtplusplus": {
"flake": false,
"locked": {
@@ -49,16 +34,16 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1643169865,
- "narHash": "sha256-+KIpNRazbc8Gac9jdWCKQkFv9bjceaLaLhlwqUEYu8c=",
+ "lastModified": 1648219316,
+ "narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "945ec499041db73043f745fad3b2a3a01e826081",
+ "rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"type": "github"
},
"original": {
"owner": "nixos",
- "ref": "nixos-unstable",
+ "ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
@@ -82,7 +67,6 @@
"root": {
"inputs": {
"flake-compat": "flake-compat",
- "flake-utils": "flake-utils",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs",
"quazip": "quazip"
diff --git a/flake.nix b/flake.nix
index 5f95b4e6..e59d6be8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,50 +1,34 @@
{
- description = "PolyMC flake";
- inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
- inputs.flake-utils.url = "github:numtide/flake-utils";
- inputs.flake-compat = {
- url = "github:edolstra/flake-compat";
- flake = false;
- };
- inputs.libnbtplusplus = {
- url = "github:multimc/libnbtplusplus";
- flake = false;
- };
- inputs.quazip = {
- url = "github:stachenov/quazip";
- flake = false;
+ description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+ flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
+ libnbtplusplus = { url = "github:multimc/libnbtplusplus"; flake = false; };
+ quazip = { url = "github:stachenov/quazip"; flake = false; };
};
- outputs = args@{ self, nixpkgs, flake-utils, libnbtplusplus, quazip, ... }:
+ outputs = { self, nixpkgs, libnbtplusplus, quazip, ... }:
let
- systems = [
- "aarch64-linux"
- # "aarch64-darwin" # qtbase is currently broken
- "i686-linux"
- "x86_64-darwin"
- "x86_64-linux"
- ];
- in {
- overlay = final: prev: {
- inherit (self.packages.${final.system}) polymc;
- };
- } // flake-utils.lib.eachSystem systems (system:
- let pkgs = import nixpkgs { inherit system; };
- in {
- packages = {
- polymc = pkgs.libsForQt5.callPackage ./packages/nix/polymc {
- inherit self;
- submoduleQuazip = quazip;
- submoduleNbt = libnbtplusplus;
- };
- };
- apps = {
- polymc = flake-utils.lib.mkApp {
- name = "polymc";
- drv = self.packages.${system}.polymc;
- };
- };
- defaultPackage = self.packages.${system}.polymc;
- defaultApp = self.apps.${system}.polymc;
- });
+ # Generate a user-friendly version number.
+ version = builtins.substring 0 8 self.lastModifiedDate;
+
+ # System types to support (qtbase is currently broken for "aarch64-darwin")
+ supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
+
+ # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
+ forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
+
+ # Nixpkgs instantiated for supported system types.
+ pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
+ in
+ {
+ packages = forAllSystems (system: { polymc = pkgs.${system}.libsForQt5.callPackage ./packages/nix/polymc { inherit version self quazip libnbtplusplus; }; });
+ defaultPackage = forAllSystems (system: self.packages.${system}.polymc);
+
+ apps = forAllSystems (system: { polymc = { type = "app"; program = "${self.defaultPackage.${system}}/bin/polymc"; }; });
+ defaultApp = forAllSystems (system: self.apps.${system}.polymc);
+
+ overlay = final: prev: { polymc = self.defaultPackage.${final.system}; };
+ };
}
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 05af3503..42348792 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -413,6 +413,11 @@ set(TASKS_SOURCES
tasks/SequentialTask.cpp
)
+add_unit_test(Task
+ SOURCES tasks/Task_test.cpp
+ LIBS Launcher_logic
+ )
+
set(SETTINGS_SOURCES
# Settings
settings/INIFile.cpp
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp
index a825e8d4..03e942f1 100644
--- a/launcher/InstanceImportTask.cpp
+++ b/launcher/InstanceImportTask.cpp
@@ -40,6 +40,14 @@ InstanceImportTask::InstanceImportTask(const QUrl sourceUrl)
m_sourceUrl = sourceUrl;
}
+bool InstanceImportTask::abort()
+{
+ m_filesNetJob->abort();
+ m_extractFuture.cancel();
+
+ return false;
+}
+
void InstanceImportTask::executeTask()
{
if (m_sourceUrl.isLocalFile())
diff --git a/launcher/InstanceImportTask.h b/launcher/InstanceImportTask.h
index a1990647..365c3dc4 100644
--- a/launcher/InstanceImportTask.h
+++ b/launcher/InstanceImportTask.h
@@ -37,6 +37,9 @@ class InstanceImportTask : public InstanceTask
public:
explicit InstanceImportTask(const QUrl sourceUrl);
+ bool canAbort() const override { return true; }
+ bool abort() override;
+
protected:
//! Entry point for tasks.
virtual void executeTask() override;
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 47c249b3..344a024e 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -53,7 +53,7 @@ class Task : public QObject {
virtual bool canAbort() const { return false; }
QString getStatus() { return m_status; }
- virtual auto getStepStatus() const -> QString { return {}; }
+ virtual auto getStepStatus() const -> QString { return m_status; }
qint64 getProgress() { return m_progress; }
qint64 getTotalProgress() { return m_progressTotal; }
diff --git a/launcher/tasks/Task_test.cpp b/launcher/tasks/Task_test.cpp
new file mode 100644
index 00000000..9b6cc2e5
--- /dev/null
+++ b/launcher/tasks/Task_test.cpp
@@ -0,0 +1,68 @@
+#include <QTest>
+#include "TestUtil.h"
+
+#include "Task.h"
+
+/* Does nothing. Only used for testing. */
+class BasicTask : public Task {
+ Q_OBJECT
+
+ friend class TaskTest;
+
+ private:
+ void executeTask() override {};
+};
+
+/* Does nothing. Only used for testing. */
+class BasicTask_MultiStep : public Task {
+ Q_OBJECT
+
+ friend class TaskTest;
+
+ private:
+ auto isMultiStep() const -> bool override { return true; }
+
+ void executeTask() override {};
+};
+
+class TaskTest : public QObject {
+ Q_OBJECT
+
+ private slots:
+ void test_SetStatus_NoMultiStep(){
+ BasicTask t;
+ QString status {"test status"};
+
+ t.setStatus(status);
+
+ QCOMPARE(t.getStatus(), status);
+ QCOMPARE(t.getStepStatus(), status);
+ }
+
+ void test_SetStatus_MultiStep(){
+ BasicTask_MultiStep t;
+ QString status {"test status"};
+
+ t.setStatus(status);
+
+ QCOMPARE(t.getStatus(), status);
+ // Even though it is multi step, it does not override the getStepStatus method,
+ // so it should remain the same.
+ QCOMPARE(t.getStepStatus(), status);
+ }
+
+ void test_SetProgress(){
+ BasicTask t;
+ int current = 42;
+ int total = 207;
+
+ t.setProgress(current, total);
+
+ QCOMPARE(t.getProgress(), current);
+ QCOMPARE(t.getTotalProgress(), total);
+ }
+};
+
+QTEST_GUILESS_MAIN(TaskTest)
+
+#include "Task_test.moc"
diff --git a/packages/nix/polymc/default.nix b/packages/nix/polymc/default.nix
index 63fc6b7e..e352209a 100644
--- a/packages/nix/polymc/default.nix
+++ b/packages/nix/polymc/default.nix
@@ -14,10 +14,11 @@
, libGL
, msaClientID ? ""
-# flake
+ # flake
, self
-, submoduleNbt
-, submoduleQuazip
+, version
+, libnbtplusplus
+, quazip
}:
let
@@ -30,7 +31,7 @@ let
libXxf86vm
libpulseaudio
libGL
- ];
+ ];
# This variable will be passed to Minecraft by PolyMC
gameLibraryPath = libpath + ":/run/opengl-driver/lib";
@@ -38,12 +39,12 @@ in
mkDerivation rec {
pname = "polymc";
- version = "nightly";
+ inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [ cmake ninja file makeWrapper ];
- buildInputs = [ qtbase jdk8 zlib ];
+ buildInputs = [ qtbase jdk zlib ];
dontWrapQtApps = true;
@@ -57,8 +58,8 @@ mkDerivation rec {
# Copy submodules inputs
rm -rf source/libraries/{libnbtplusplus,quazip}
mkdir source/libraries/{libnbtplusplus,quazip}
- cp -a ${submoduleNbt}/* source/libraries/libnbtplusplus
- cp -a ${submoduleQuazip}/* source/libraries/quazip
+ cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
+ cp -a ${quazip}/* source/libraries/quazip
chmod a+r+w source/libraries/{libnbtplusplus,quazip}/*
'';