diff --git a/.gitignore b/.gitignore index ec9de82..3eff1f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target /scripts *.log +result +result-* +.direnv diff --git a/README.md b/README.md index 4cfc36d..cf36761 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,25 @@ paru -S rmcl-bin paru -S rmcl-git ``` +### Nix + +[![Nix](https://img.shields.io/badge/nix-5277C4?style=for-the-badge&logo=nixos)](https://github.com/objz/rmcl) + +```sh +nix run github:objz/rmcl +nix profile install github:objz/rmcl +``` + +the flake builds rmcl from source. To use your own key instead, override it +at build time: + +```sh +CURSEFORGE_API_KEY=your-key nix build --impure .# +``` + +Minecraft 1.12 and older currently fail to launch because rmcl doesn't pass +`-Djava.library.path` for legacy version profiles. + ### Cargo [![crates.io](https://img.shields.io/crates/v/rmcl?style=for-the-badge&logo=rust)](https://crates.io/crates/rmcl) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8ce208f --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1790570722, + "narHash": "sha256-Avcz96Q+8OkfUIUXipBBVsQn19L622BtKP7mk6M+uls=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "419fe0f449b3fbe3bdd53d9840288db4509ec32e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1f8de68 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + description = "rmcl: A fully featured Minecraft TUI launcher"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + # release binaries have the curseforge key compiled in; source builds + # don't, so forward the caller's key when building impurely. + curseforgeApiKey = builtins.getEnv "CURSEFORGE_API_KEY"; + # minecraft's bundled lwjgl natives dlopen the host's x11 stack, which + # isn't on the default loader path on nixos. java is spawned as a child + # of rmcl, so a wrapper LD_LIBRARY_PATH propagates all the way down. + runtimeLibs = pkgs.lib.makeLibraryPath (with pkgs; [ + libX11 + libXext + libXcursor + libXrandr + libXxf86vm + ]); + in { + packages.default = pkgs.rustPlatform.buildRustPackage { + pname = "rmcl"; + version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; + src = pkgs.lib.cleanSource ./.; + cargoLock.lockFile = ./Cargo.lock; + nativeBuildInputs = [pkgs.jdk pkgs.makeWrapper]; + buildInputs = [pkgs.libxcb]; + + env = pkgs.lib.optionalAttrs (curseforgeApiKey != "") { + CURSEFORGE_API_KEY = curseforgeApiKey; + }; + + postFixup = '' + wrapProgram $out/bin/rmcl --prefix LD_LIBRARY_PATH : ${runtimeLibs} + ''; + + meta = with pkgs.lib; { + description = "A fully featured Minecraft TUI launcher"; + homepage = "https://github.com/objz/rmcl"; + license = licenses.gpl3Only; + mainProgram = "rmcl"; + }; + }; + }); +}