Feat: Nix Flake install method with ci

This commit is contained in:
Edward Groves 2026-07-16 13:56:09 -04:00
parent 4a561a0c78
commit 8e68fbfe0b
6 changed files with 296 additions and 0 deletions

38
.github/workflows/nix.yml vendored Normal file
View file

@ -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

4
.gitignore vendored
View file

@ -24,6 +24,10 @@
.DS_Store
Thumbs.db
# Nix
/result
/result-*
# Log files
*.log

View file

@ -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.<system>.default` (or `emerald-legacy-launcher`) from it.
**Flatpak Installation:**
```bash
flatpak install emerald.flatpak

27
flake.lock Normal file
View file

@ -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
}

83
flake.nix Normal file
View file

@ -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);
};
}

131
nix/package.nix Normal file
View file

@ -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 = [ ];
};
})