From b488cc354589d978531a2e0efd64265ba88e7e2f Mon Sep 17 00:00:00 2001 From: Thorn Avery Date: Fri, 15 Mar 2024 09:09:12 +1300 Subject: [PATCH] updated makefile for rgbds 7.0 + nix automatic environment --- Makefile | 2 +- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Makefile b/Makefile index f89b849..9c66400 100644 --- a/Makefile +++ b/Makefile @@ -175,7 +175,7 @@ gfx/pokedex/pokedex.2bpp: tools/gfx += --trim-whitespace gfx/pokedex/pokedex_sgb.2bpp: tools/gfx += --trim-whitespace gfx/pokedex/question_mark.2bpp: rgbgfx += -Z gfx/pokedex/slowpoke.2bpp: tools/gfx += --trim-whitespace -gfx/pokedex/question_mark.2bpp: rgbgfx += -h +gfx/pokedex/question_mark.2bpp: rgbgfx += -Z gfx/pokegear/pokegear.2bpp: rgbgfx += -x2 gfx/pokegear/pokegear_sprites.2bpp: tools/gfx += --trim-whitespace diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8c1375e --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "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": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "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..686fc7e --- /dev/null +++ b/flake.nix @@ -0,0 +1,77 @@ +{ + description = "Johto Expansion Pack Romhack"; + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05; + flake-utils.url = github:numtide/flake-utils; + }; + outputs = { self, nixpkgs, flake-utils, ... }: + let + jepDerivation = { stdenv, src, pkgs, + make ? pkgs.gnumake, + gcc ? pkgs.gcc, + rgbds ? pkgs.rgbds, + files ? ["*.*gb*"], + # python3 ? pkgs.python3, + }: stdenv.mkDerivation rec { + src = ./.; + name = "jep-hack"; + buildInputs = [ rgbds gcc make ]; + installPhase = '' + shopt -s extglob + mkdir $out + ${builtins.concatStringsSep "\n" (map (item: + if builtins.isList item && (builtins.length item == 2) + then "mv ${builtins.elemAt item 0} $out/${builtins.elemAt item 1}" + else "cp ${item}* $out" + ) files)} + ''; + }; + in flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { inherit system; overlays = [self.overlays.default]; }; + rgbds_7_0 = + pkgs.rgbds.overrideAttrs (oldAttrs: { + postPatch = '' + if [[ -d $PWD/src ]]; then + export PATH=$PWD/src:$PATH + chmod +x $PWD/src/* + patchShebangs $PWD + fi + ''; + version = "0.7.0"; + src = pkgs.fetchFromGitHub { + owner = "gbdev"; + repo = "rgbds"; + rev = "08f3e360c9525b65291db9cee66fc5eb6e4a45e4"; + sha256 = "sha256-aktKJlwXpHpjSFxoz5wZJPGWZIcn4ax5iBP0GQEux78="; + }; + }); + in { + packages = { + default = pkgs.jep-hack; + jep-hack = pkgs.jep-hack; + rgbds_7_0 = rgbds_7_0; + }; + devShells = { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + rgbds_7_0 + gcc + gnumake + sameboy + imagemagick + ]; + }; + }; + }) // { + overlays = { + default = final: prev: { + jep-hack = final.callPackage jepDerivation { + files = [ + ["pokecrystal.gbc" "johto-expansion-pak.gbc"] + ["pokecrystal.sym" "johto-expansion-pak.sym"] + ]; + }; + }; + }; + }; +}