From d5513f791fa87ea5fbf3d89ccc583e4158ee85cd Mon Sep 17 00:00:00 2001 From: ruben Date: Mon, 13 May 2024 16:54:55 +0000 Subject: [PATCH] Add flake.nix, use fixed github commit to get nicer nix commands. --- README.md | 6 +++++ flake.lock | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 58 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 57911ac..b5cafb5 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ RSP microcode can also be recompiled with this tool. Currently there is no suppo ## Building This project can be built with CMake 3.20 or above and a C++ compiler that supports C++20. This repo uses git submodules, so be sure to clone recursively (`git clone --recurse-submodules`) or initialize submodules recursively after cloning (`git submodule update --init --recursive`). From there, building is identical to any other cmake project, e.g. run `cmake` in the target build folder and point it at the root of this repo, then run `cmake --build .` from that target folder. +## Nix +If you are using nixos or have [nix installed](https://nixos.org/) +This project can be built and run using nix flakes, to spawn a shell with both, N64Recomp and RSPRecomp programs available you can perform the command: + +`nix shell github:Mr-Wiseguy/N64Recomp` + ## Libraries Used * [rabbitizer](https://github.com/Decompollaborate/rabbitizer) for instruction decoding/analysis * [ELFIO](https://github.com/serge1/ELFIO) for elf parsing diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..04d130d --- /dev/null +++ b/flake.lock @@ -0,0 +1,78 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1715534503, + "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2057814051972fa1453ddfb0d98badbea9b83c06", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "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..0238da8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Tool to statically recompile N64 games into native executables"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + flake-utils.url = "github:numtide/flake-utils"; + + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = inputs @ {...}: + inputs.flake-utils.lib.eachDefaultSystem + ( + system: let + pkgs = import inputs.nixpkgs { + inherit system; + }; + in rec { + packages = rec { + N64Recomp = pkgs.stdenv.mkDerivation { + pname = "N64Recomp"; + version = "1.0.0"; + src = pkgs.fetchFromGitHub { + owner = "Mr-Wiseguy"; + repo = "N64Recomp"; + rev = "d7b223fde51c651d2e1aa856efaf19793a77e5e7"; + deepClone = true; + fetchSubmodules = true; + hash = "sha256-TWr6ctsT3VaSRvsTfVBC5sBPCx4b2rvUuuZFUGO6kH4="; + }; + nativeBuildInputs = [pkgs.cmake]; + + installPhase = '' + mkdir -p $out/bin + cp N64Recomp $out/bin + cp RSPRecomp $out/bin + ''; + }; + default = N64Recomp; + }; + apps = rec { + N64Recomp = { + type = "app"; + program = "${packages.N64Recomp}/bin/N64Recomp"; + }; + + RSPRecomp = { + type = "app"; + program = "${packages.N64Recomp}/bin/RSPRecomp"; + }; + default = N64Recomp; + }; + } + ); +} \ No newline at end of file