feat: shell with emulator

This commit is contained in:
Kat Inskip 2025-07-24 20:45:48 -07:00
parent f21118f9f7
commit cdaa9c1514
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
5 changed files with 37 additions and 22 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

View file

@ -19,3 +19,15 @@ nix build .#katgba
# Use mgba-qt with a built rom # Use mgba-qt with a built rom
nix run .#katgba-emu nix run .#katgba-emu
``` ```
## Shell
```
# Allow permissions for direnv to use shell
direnv allow
# or consume with `nix develop`
nix develop
# Use mgba-qt with a built rom
katgba-emu
```

View file

@ -60,18 +60,23 @@
rustToolchain = rustToolchainFor pkgs; rustToolchain = rustToolchainFor pkgs;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchainFor; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchainFor;
katgba-emu = pkgs.callPackage ./katgba-emu.nix { inherit katgba; };
myPackage = pkgs.callPackage ./package.nix { inherit craneLib rustToolchain rustTriple; }; katgba = pkgs.callPackage ./package.nix { inherit craneLib rustToolchain rustTriple; };
in { in {
packages = { devShells = let
default = myPackage; katgba-emu = pkgs.mkShell {
katgba = myPackage; nativeBuildInputs = [
self.packages.${pkgs.system}.katgba-emu
];
}; };
apps = rec { in {
katgba-emu = flake-utils.lib.mkApp { drv = pkgs.writeShellScriptBin "katgba-emu" ''
${pkgs.mgba}/bin/mgba-qt ${lib.getExe' self.packages.${system}.default "katgba"}
''; };
default = katgba-emu; default = katgba-emu;
inherit katgba-emu;
};
packages = {
default = katgba;
katgba-emu = katgba-emu;
inherit katgba;
}; };
}); });
} }

7
katgba-emu.nix Normal file
View file

@ -0,0 +1,7 @@
{ writeShellScriptBin, mgba, lib, katgba }:
let
inherit (lib.meta) getExe';
in writeShellScriptBin "katgba-emu" ''
${mgba}/bin/mgba-qt ${getExe' katgba "katgba"}
''

View file

@ -1,10 +0,0 @@
{
mkShell,
mgba,
rust-bin
}: mkShell {
packages = [
rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)
];
};