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/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}/* '';