From 8e68fbfe0b1fb6878f507c78a9a344c393da65a1 Mon Sep 17 00:00:00 2001 From: Edward Groves Date: Thu, 16 Jul 2026 13:56:09 -0400 Subject: [PATCH] Feat: Nix Flake install method with ci --- .github/workflows/nix.yml | 38 +++++++++++ .gitignore | 4 ++ README.md | 13 ++++ flake.lock | 27 ++++++++ flake.nix | 83 ++++++++++++++++++++++++ nix/package.nix | 131 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 296 insertions(+) create mode 100644 .github/workflows/nix.yml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..447ee2c --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,38 @@ +name: Nix + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + id-token: write + +concurrency: + group: nix-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: DeterminateSystems/nix-installer-action@main + + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Build package + run: nix build .#default --print-build-logs + + - name: Flake check + run: nix flake check --print-build-logs + + - name: Verify outputs + run: | + test -x ./result/bin/emerald-legacy-launcher + nix path-info -Sh ./result + ls -la ./result/bin/ + ls -la ./result/share/applications/ || true diff --git a/.gitignore b/.gitignore index f701a55..a2928d6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,10 @@ .DS_Store Thumbs.db +# Nix +/result +/result-* + # Log files *.log diff --git a/README.md b/README.md index 6f2d1ba..fc9614b 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Multiple distribution formats available: | `.rpm` | RHEL, Fedora, openSUSE | | `.AppImage` | Universal (no installation required) | | `.flatpak` | Universal with sandboxing (recommended over AppImage) | +| Nix flake | NixOS and any Linux with [Nix](https://nixos.org/download/) installed | **AUR:** Special thanks to [AntiApple4life](https://aur.archlinux.org/packages?O=0&SeB=m&K=AntiApple4life) for the AUR packages! @@ -122,6 +123,18 @@ paru -S emerald-legacy-launcher # or yay paru -S emerald-legacy-launcher-bin # or yay ``` +**Nix:** +Requires [Nix](https://nixos.org/download/) with flakes enabled (`experimental-features = nix-command flakes` in `nix.conf`). +```bash +# Run without installing +nix run github:LCE-Hub/LCE-Emerald-Launcher + +# Install to your user profile +nix profile install github:LCE-Hub/LCE-Emerald-Launcher +``` + +On NixOS, add the flake as an input and install `packages..default` (or `emerald-legacy-launcher`) from it. + **Flatpak Installation:** ```bash flatpak install emerald.flatpak diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5b993c3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1784120854, + "narHash": "sha256-KesHgItiZPgGX740axSiQLcIQ8D24MDqNpkKYWIek8k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "753cc8a3a87467296ddd1fa93f0cc3e81120ee46", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a371015 --- /dev/null +++ b/flake.nix @@ -0,0 +1,83 @@ +{ + description = "LCE Emerald Launcher — FOSS cross-platform launcher for Minecraft Legacy Console Edition"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + inherit (nixpkgs) lib; + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = lib.genAttrs systems; + pkgsFor = + system: + import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + in + { + overlays.default = final: _prev: { + emerald-legacy-launcher = final.callPackage ./nix/package.nix { + src = self; + }; + }; + + packages = forAllSystems ( + system: + let + pkgs = pkgsFor system; + in + { + default = pkgs.emerald-legacy-launcher; + emerald-legacy-launcher = pkgs.emerald-legacy-launcher; + } + ); + + apps = forAllSystems (system: { + default = { + type = "app"; + program = lib.getExe self.packages.${system}.default; + }; + }); + + checks = forAllSystems (system: { + package = self.packages.${system}.default; + }); + + devShells = forAllSystems ( + system: + let + pkgs = pkgsFor system; + in + { + default = pkgs.mkShell { + inputsFrom = [ pkgs.emerald-legacy-launcher ]; + packages = with pkgs; [ + cargo + rustc + rustfmt + clippy + cargo-tauri + nodejs + pnpm_10 + pkg-config + ]; + shellHook = '' + echo "Emerald Legacy Launcher dev shell" + echo " pnpm install && pnpm tauri dev" + ''; + }; + } + ); + + formatter = forAllSystems (system: (pkgsFor system).nixfmt); + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..1c2db27 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,131 @@ +{ + lib, + stdenv, + rustPlatform, + cargo-tauri, + nodejs, + pkg-config, + pnpm_10, + fetchPnpmDeps, + pnpmConfigHook, + wrapGAppsHook4, + openssl, + webkitgtk_4_1, + glib-networking, + libayatana-appindicator, + librsvg, + udev, + src ? null, +}: + +# Disable updater artifact signing — Nix builds have no Tauri signing key. +let + tauriConfOverride = builtins.toFile "tauri-nix.conf.json" '' + { + "bundle": { + "createUpdaterArtifacts": false + } + } + ''; + + defaultSrc = lib.cleanSourceWith { + src = ../.; + filter = + path: _type: + let + baseName = baseNameOf path; + in + !(builtins.elem baseName [ + ".git" + "node_modules" + "target" + "dist" + "build-flatpak" + "emerald-repo" + "result" + "result-dev" + ]); + }; +in +rustPlatform.buildRustPackage (finalAttrs: { + pname = "emerald-legacy-launcher"; + version = "1.5.1"; + + src = if src != null then src else defaultSrc; + + cargoRoot = "src-tauri"; + buildAndTestSubdir = finalAttrs.cargoRoot; + + cargoHash = "sha256-tSbFyle2eQ5Dw9fTXloIepOZU1UxhkF6/KZBRXehm4w="; + + pnpmDeps = fetchPnpmDeps { + inherit (finalAttrs) pname version src; + pnpm = pnpm_10; + fetcherVersion = 3; + hash = "sha256-6na8YlSTkdnSse8DQjBnTBpfmKSYj3+1FLWVyyfUx1g="; + }; + + nativeBuildInputs = [ + cargo-tauri.hook + nodejs + pkg-config + pnpmConfigHook + pnpm_10 + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ wrapGAppsHook4 ]; + + buildInputs = [ + openssl + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + glib-networking + libayatana-appindicator + librsvg + udev + webkitgtk_4_1 + ]; + + tauriBuildFlags = [ + "-c" + tauriConfOverride + ]; + + postPatch = lib.optionalString stdenv.hostPlatform.isLinux '' + substituteInPlace "$cargoDepsCopy"/*/libappindicator-sys-*/src/lib.rs \ + --replace-fail "libayatana-appindicator3.so.1" \ + "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" + ''; + + # Prefer the project's pnpm frontend build over the npm beforeBuildCommand. + preBuild = '' + substituteInPlace src-tauri/tauri.conf.json \ + --replace-fail '"beforeBuildCommand": "npm run build"' \ + '"beforeBuildCommand": "pnpm run build"' + ''; + + preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : ${ + lib.makeLibraryPath [ + libayatana-appindicator + udev + ] + } + ) + ''; + + doCheck = false; + + env = { + CI = "true"; + }; + + meta = { + description = "FOSS cross-platform launcher for Minecraft Legacy Console Edition"; + homepage = "https://github.com/LCE-Hub/LCE-Emerald-Launcher"; + license = lib.licenses.gpl3Only; + mainProgram = "emerald-legacy-launcher"; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + maintainers = [ ]; + }; +})