From 3cb6bc95b9dc03a534a3af0496ff5d5de6069f8e Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 12:00:45 +0330 Subject: [PATCH 01/25] Experimental flake --- flake.lock | 48 ++++++++++++ flake.nix | 36 +++++++++ pcsx-redux.nix | 204 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 pcsx-redux.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..4c8c8a0d7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1733940404, + "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-github-actions": "nix-github-actions", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..ff42b983f --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = ""; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nix-github-actions.url = "github:nix-community/nix-github-actions"; + nix-github-actions.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + nix-github-actions, + ... + }: + let + ignorePaths = [ + # ".github" + # ".gitignore" + # "flake.nix" + # "flake.lock" + # "pcsx-redux.nix" + ]; + # TODO: do all platforms + pkgs = import nixpkgs { system = "x86_64-linux"; }; + in + { + githubActions = nix-github-actions.lib.mkGithubMatrix { + + checks = self.packages; + }; + packages."x86_64-linux" = { + # TODO: debug should be another output not another derivation + pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { src = self; }; + }; +} diff --git a/pcsx-redux.nix b/pcsx-redux.nix new file mode 100644 index 000000000..c0396ac95 --- /dev/null +++ b/pcsx-redux.nix @@ -0,0 +1,204 @@ +{ + stdenv, + lib, + fetchFromGitHub, + libuv, + zlib, + curl, + ffmpeg, + glfw3, + capstone, + freetype, + libX11, + pkg-config, + imagemagick, + # luajit, + luajitPackages, + multipart-parser-c, + fmt, + magic-enum, + miniaudio, + gtest, + tl-expected, + elfio, + tracy, + md4c, + stb, + uriparser, + ucl, + llhttp, + + debugBuild ? false, + src +}: +let +# get rid of this nonsense + zep = fetchFromGitHub { + owner = "grumpycoders"; + repo = "zep"; + rev = "86ea3c7019f45ccd4a13503bf7d98a396e8f0193"; + hash = "sha256-6NmUlOHkRQvCgbATcNxnFrfA2ZWROPYN8Vpd10k6Z2g="; + }; + nanosvg = fetchFromGitHub { + owner = "grumpycoders"; + repo = "nanosvg"; + rev = "f0a3e1034dd22e2e87e5db22401e44998383124e"; + hash = "sha256-af11kAga6Ru2rPgrfcYswXNy9etvH3J9FX2T0I0++ew="; + }; + nanovg = fetchFromGitHub { + owner = "grumpycoders"; + repo = "nanovg"; + rev = "7c021819bbd4843a1a3091fe47346d3fcb2a3e1a"; + hash = "sha256-gZHbNuDkLXlLlXZZpLBHcbwzTfeBBkLY7xl4L5yr2lY="; + }; + imgui-md = fetchFromGitHub { + owner = "mekhontsev"; + repo = "imgui_md"; + rev = "8ca75c5f7663f314821e3d0b2c51011792bee68f"; + hash = "sha256-uxhY81DWLRRCceYn9khk3rwzT+2f9PNMIMT9OrkPfFc="; + }; + xbyak = fetchFromGitHub { + owner = "herumi"; + repo = "xbyak"; + rev = "2fb843c3287918038c8f76276a590c25cc7ec5ee"; + hash = "sha256-XZce+kEZ7dipI19WY43ycOjzM2dZyANMEN5+GhoNYUk="; + }; + luafs = fetchFromGitHub { + owner = "lunarmodules"; + repo = "luafilesystem"; + rev = "912e06714fc276c15b4d5d1b42bd2b11edb8deff"; + hash = "sha256-BShByo2NhVrOHDPze/JXfeFWq36PFrI2HVugR2MDB0A="; + }; + luajit = fetchFromGitHub { + owner = "grumpycoders"; + repo = "luajit"; + rev = "66fadd16a51955cfbd770de62806cfbdd7c6c818"; + hash = "sha256-nFlDr79GC8MsL6ausAsEPJwL8OJrFydB37tpD5mS1C8="; + }; + imgui = fetchFromGitHub { + owner = "ocornut"; + repo = "imgui"; + rev = "368123ab06b2b573d585e52f84cd782c5c006697"; + hash = "sha256-6VOs7a31bEfAG75SQAY2X90h/f/HvqZmN615WXYkUOA="; + }; + sdl-db = fetchFromGitHub { + owner = "mdqinc"; + repo = "SDL_GameControllerDB"; + rev = "b1e342774cbb35467dfdd3634d4f0181a76cbc89"; + hash = "sha256-LYvO+chDVo6D++fuFbxqSRltGW3y82SESmtFj39TdSA="; + }; + # commit = "faee80688fa03d924437118b28720184b7b58de1"; +in stdenv.mkDerivation { + pname = "pcsx-redux"; + version = "0.99test"; + inherit src; +/* + src = fetchFromGitHub { + owner = "grumpycoders"; + # owner = "NotExactlySiev"; + repo = "pcsx-redux"; + rev = commit; + hash = "sha256-qbpeNCv7jsRBg7GOn/EAm1A2K3F/zHuMHF/bBOb9q0o="; + }; +*/ + + postUnpack = '' + rmdir source/third_party/miniaudio + rmdir source/third_party/zep + rmdir source/third_party/nanosvg + rmdir source/third_party/nanovg + rmdir source/third_party/imgui + rmdir source/third_party/imgui_md + rmdir source/third_party/xbyak + rmdir source/third_party/luafilesystem + rmdir source/third_party/luv + rmdir source/third_party/SDL_GameControllerDB + rmdir source/third_party/tracy + rmdir source/third_party/luajit + + cp -r ${miniaudio.out} source/third_party/miniaudio + cp -r ${zep.out} source/third_party/zep + cp -r ${nanosvg.out} source/third_party/nanosvg + cp -r ${nanovg.out} source/third_party/nanovg + cp -r ${imgui.out} source/third_party/imgui + cp -r ${imgui-md.out} source/third_party/imgui_md + cp -r ${xbyak.out} source/third_party/xbyak + cp -r ${luafs.out} source/third_party/luafilesystem + cp -r ${sdl-db.out} source/third_party/SDL_GameControllerDB + cp -r ${tracy.src} source/third_party/tracy + cp -r ${luajit.out} source/third_party/luajit + + chmod -R +w source/third_party/miniaudio + chmod -R +w source/third_party/zep + chmod -R +w source/third_party/nanosvg + chmod -R +w source/third_party/nanovg + chmod -R +w source/third_party/imgui + chmod -R +w source/third_party/imgui_md + chmod -R +w source/third_party/luafilesystem + chmod -R +w source/third_party/SDL_GameControllerDB + chmod -R +w source/third_party/tracy + chmod -R +w source/third_party/luajit + ''; + + patches = [ + ./001-patch.diff + ]; + + nativeBuildInputs = [ + pkg-config + imagemagick + ]; + + buildInputs = [ + stb + ucl + #imgui + md4c + # luajit + # luajitPackages.lpeg + #luajitPackages.luafilesystem + #luajitPackages.lua-protobuf + luajitPackages.libluv + multipart-parser-c + fmt + magic-enum + gtest + tl-expected + elfio + libuv + tracy + curl.dev + zlib + ffmpeg.dev + glfw3 + capstone + freetype.dev + uriparser + libX11 + llhttp + ]; + + runtimeDependencies = [ + # zlib + ]; + + makeFlags = [ + "DESTDIR=$(out)" + ]; + + # TODO: learn how to use separate debug info + dontStrip = debugBuild; + enableDebugging = debugBuild; + + enableParallelBuilding = true; + NIX_BUILD_CORES = 10; + + meta = { + homepage = "https://pcsx-redux.consoledev.net"; + description = "PlayStation 1 emulator and debugger"; + #license = lib.licenses.gpl3Only; + mainProgram = "pcsx-redux"; + #maintainers = with lib.maintainers; [ guibou AndersonTorres ]; + platforms = lib.platforms.linux; + }; +} From ba4fa071b4a94187690a5ce21cc1beb4fb0b2bb9 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 12:07:41 +0330 Subject: [PATCH 02/25] Fix flake.nix --- 001-patch.diff | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 001-patch.diff diff --git a/001-patch.diff b/001-patch.diff new file mode 100644 index 000000000..ce7c09a80 --- /dev/null +++ b/001-patch.diff @@ -0,0 +1,100 @@ +diff --git a/Makefile b/Makefile +index 3edc8c93..54cf8c37 100644 +--- a/Makefile ++++ b/Makefile +@@ -8,7 +8,7 @@ UNAME_M := $(shell uname -m) + rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) + CC_IS_CLANG := $(shell $(CC) --version | grep -q clang && echo true || echo false) + +-PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib libcurl ++PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib libcurl fmt md4c libluv liburiparser libllhttp + + LOCALES := el es_ES fr ja pt_BR uk zh_CN + +@@ -23,8 +23,6 @@ CPPFLAGS += `pkg-config --cflags $(PACKAGES)` + CPPFLAGS += -I. + CPPFLAGS += -Isrc + CPPFLAGS += -Ithird_party +-CPPFLAGS += -Ithird_party/ELFIO +-CPPFLAGS += -Ithird_party/fmt/include/ + CPPFLAGS += -Ithird_party/gl3w + CPPFLAGS += -Ithird_party/googletest/googletest/include + CPPFLAGS += -Ithird_party/imgui +@@ -32,16 +30,10 @@ CPPFLAGS += -Ithird_party/imgui/backends + CPPFLAGS += -Ithird_party/imgui/examples + CPPFLAGS += -Ithird_party/imgui/misc/cpp + CPPFLAGS += -Ithird_party/libelfin +-CPPFLAGS += -Ithird_party/llhttp + CPPFLAGS += -Ithird_party/luajit/src +-CPPFLAGS += -Ithird_party/luv/src +-CPPFLAGS += -Ithird_party/luv/deps/lua-compat-5.3/c-api + CPPFLAGS += -Ithird_party/magic_enum/include/magic_enum +-CPPFLAGS += -Ithird_party/md4c/src + CPPFLAGS += -Ithird_party/multipart-parser-c + CPPFLAGS += -Ithird_party/tracy/public +-CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include +-CPPFLAGS += -Ithird_party/uriparser/include + CPPFLAGS += -Ithird_party/zep/extensions + CPPFLAGS += -Ithird_party/zep/include + CPPFLAGS += -Ithird_party/xbyak/xbyak +@@ -86,6 +78,8 @@ else + endif + + LDFLAGS += third_party/luajit/src/libluajit.a ++LDFLAGS += -lucl ++LDFLAGS += -lmultipart + LDFLAGS += -ldl + LDFLAGS += -g + +@@ -109,7 +103,6 @@ endif + LD := $(CXX) + + SRCS := $(call rwildcard,src/,*.cc) +-SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc + IMGUI_SRCS += $(wildcard third_party/imgui/*.cpp) + VIXL_SRCS := $(call rwildcard, third_party/vixl/src,*.cc) + SRCS += $(IMGUI_SRCS) +@@ -129,16 +122,10 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp + SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp + SRCS += third_party/imgui_md/imgui_md.cpp + SRCS += third_party/imgui_memory_editor/imgui_memory_editor.cpp +-SRCS += $(wildcard third_party/llhttp/*.c) + SRCS += $(wildcard third_party/lpeg/*.c) + SRCS += third_party/lua-protobuf/pb.c + SRCS += third_party/luafilesystem/src/lfs.c +-SRCS += third_party/luv/src/luv.c +-SRCS += third_party/md4c/src/md4c.c +-SRCS += third_party/multipart-parser-c/multipart_parser.c + SRCS += third_party/nanovg/src/nanovg.c +-SRCS += third_party/tracy/public/TracyClient.cpp +-SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c + SRCS += $(wildcard third_party/uriparser/src/*.c) + SRCS += third_party/zep/extensions/repl/mode_repl.cpp + SRCS += $(wildcard third_party/zep/src/*.cpp) +@@ -167,8 +154,6 @@ ifeq ($(CROSS),arm64) + endif + SUPPORT_SRCS := src/support/file.cc src/support/mem4g.cc src/support/zfile.cc + SUPPORT_SRCS += src/supportpsx/adpcm.cc src/supportpsx/binloader.cc src/supportpsx/ps1-packer.cc +-SUPPORT_SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc +-SUPPORT_SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c + SUPPORT_SRCS += $(wildcard third_party/iec-60908b/*.c) + OBJECTS := third_party/luajit/src/libluajit.a + +diff --git a/src/main/main.cc b/src/main/main.cc +index 850617ee..cecc64f4 100644 +--- a/src/main/main.cc ++++ b/src/main/main.cc +@@ -364,11 +364,12 @@ runner.init({ + luacovEnabled = false; + } + } ++/* + emulator->setLua(); + s_ui->setLua(*emulator->m_lua); + emulator->m_spu->setLua(*emulator->m_lua); + assert(emulator->m_lua->gettop() == 0); +- ++*/ + // Starting up the whole emulator; we delay setting the GPU only now because why not. + auto &emuSettings = emulator->settings; + emulator->m_spu->open(); diff --git a/flake.nix b/flake.nix index ff42b983f..d791efc44 100644 --- a/flake.nix +++ b/flake.nix @@ -26,11 +26,11 @@ in { githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = self.packages; }; packages."x86_64-linux" = { # TODO: debug should be another output not another derivation pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { src = self; }; + }; }; } From 4bc9fb6737574bc2c8b97ae71ef647810f3c723a Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 12:20:07 +0330 Subject: [PATCH 03/25] Remove unneeded rmdir's --- pcsx-redux.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pcsx-redux.nix b/pcsx-redux.nix index c0396ac95..6a1d8ee11 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -103,18 +103,18 @@ in stdenv.mkDerivation { */ postUnpack = '' - rmdir source/third_party/miniaudio - rmdir source/third_party/zep - rmdir source/third_party/nanosvg - rmdir source/third_party/nanovg - rmdir source/third_party/imgui - rmdir source/third_party/imgui_md - rmdir source/third_party/xbyak - rmdir source/third_party/luafilesystem - rmdir source/third_party/luv - rmdir source/third_party/SDL_GameControllerDB - rmdir source/third_party/tracy - rmdir source/third_party/luajit + # rmdir source/third_party/miniaudio + # rmdir source/third_party/zep + # rmdir source/third_party/nanosvg + # rmdir source/third_party/nanovg + # rmdir source/third_party/imgui + # rmdir source/third_party/imgui_md + # rmdir source/third_party/xbyak + # rmdir source/third_party/luafilesystem + # rmdir source/third_party/luv + # rmdir source/third_party/SDL_GameControllerDB + # rmdir source/third_party/tracy + # rmdir source/third_party/luajit cp -r ${miniaudio.out} source/third_party/miniaudio cp -r ${zep.out} source/third_party/zep From acadec0b4a6531bf2a40a67a14b01bdbbb5dd7ff Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 12:29:33 +0330 Subject: [PATCH 04/25] Add CI for Nix flake --- .../workflows/cachix-install-nix-action.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/cachix-install-nix-action.yml diff --git a/.github/workflows/cachix-install-nix-action.yml b/.github/workflows/cachix-install-nix-action.yml new file mode 100644 index 000000000..91d9b27eb --- /dev/null +++ b/.github/workflows/cachix-install-nix-action.yml @@ -0,0 +1,31 @@ +name: Nix Flake actions + +on: + pull_request: + push: + +jobs: + nix-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + - id: set-matrix + name: Generate Nix Matrix + run: | + set -Eeu + matrix="$(nix eval --json '.#githubActions.matrix')" + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" + + nix-build: + name: ${{ matrix.name }} (${{ matrix.system }}) + needs: nix-matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + - run: nix build -L '.#${{ matrix.attr }}' From 3e433c7c32c67f322fdc902341b341c0335ee4a9 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 12:40:28 +0330 Subject: [PATCH 05/25] Limit Nix derivation to 2 cores --- pcsx-redux.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcsx-redux.nix b/pcsx-redux.nix index 6a1d8ee11..7cf973e55 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -191,7 +191,8 @@ in stdenv.mkDerivation { enableDebugging = debugBuild; enableParallelBuilding = true; - NIX_BUILD_CORES = 10; + # NIX_BUILD_CORES = 10; + NIX_BUILD_CORES = 2; meta = { homepage = "https://pcsx-redux.consoledev.net"; From d580286a43f1abea0dbf7dc6b8ef97d87c0eaf4c Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 16:53:28 +0330 Subject: [PATCH 06/25] Nix: Add other systems to flake --- flake.nix | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/flake.nix b/flake.nix index d791efc44..3f9d7abfa 100644 --- a/flake.nix +++ b/flake.nix @@ -14,23 +14,17 @@ ... }: let - ignorePaths = [ - # ".github" - # ".gitignore" - # "flake.nix" - # "flake.lock" - # "pcsx-redux.nix" - ]; - # TODO: do all platforms - pkgs = import nixpkgs { system = "x86_64-linux"; }; - in - { - githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = self.packages; - }; - packages."x86_64-linux" = { - # TODO: debug should be another output not another derivation + lib = nixpkgs.lib; + forAllSystems = lib.genAttrs lib.systems.flakeExposed; + in { + packages = forAllSystems (system: + let pkgs = { inherit system; }; + in { pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { src = self; }; + default = self.packages.${system}.pcsx-redux; + }); + + githubActions = nix-github-actions.lib.mkGithubMatrix { + checks = forAllSystems self.packages; }; - }; } From 530c914954e93ff9143431c32e3a86db648fea4d Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 16:54:24 +0330 Subject: [PATCH 07/25] Nix: syntax error --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 3f9d7abfa..7e25149fd 100644 --- a/flake.nix +++ b/flake.nix @@ -27,4 +27,5 @@ githubActions = nix-github-actions.lib.mkGithubMatrix { checks = forAllSystems self.packages; }; + }; } From d7d6bfd877d7ad536db24207ffd230c4331b483e Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 16:59:18 +0330 Subject: [PATCH 08/25] Fix flake --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 7e25149fd..8d8060f0f 100644 --- a/flake.nix +++ b/flake.nix @@ -18,14 +18,14 @@ forAllSystems = lib.genAttrs lib.systems.flakeExposed; in { packages = forAllSystems (system: - let pkgs = { inherit system; }; + let pkgs = import nixpkgs { inherit system; }; in { pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { src = self; }; default = self.packages.${system}.pcsx-redux; }); githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = forAllSystems self.packages; + checks = forAllSystems (system: self.packages.${system}); }; }; } From 5c9930bdb43481a6685b0c1042d2e9c449f368b8 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:04:42 +0330 Subject: [PATCH 09/25] Nix: Limit Github actions to supported platforms --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 8d8060f0f..396b3cae3 100644 --- a/flake.nix +++ b/flake.nix @@ -10,12 +10,13 @@ outputs = { self, nixpkgs, - nix-github-actions, - ... + nix-github-actions }: let + githubSystems = builtins.attrNames nix-github-actions.githubPlatforms; lib = nixpkgs.lib; forAllSystems = lib.genAttrs lib.systems.flakeExposed; + forGithubSystems = lib.genAttrs githubSystems; in { packages = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; @@ -25,7 +26,7 @@ }); githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = forAllSystems (system: self.packages.${system}); + checks = forGithubSystems (system: self.packages.${system}); }; }; } From 13b89535a24b9c2e16d7f3e5b2c8b27793b09ab0 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:06:22 +0330 Subject: [PATCH 10/25] Nix: flake typo --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 396b3cae3..3f3216f85 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,7 @@ nix-github-actions }: let - githubSystems = builtins.attrNames nix-github-actions.githubPlatforms; + githubSystems = builtins.attrNames nix-github-actions.lib.githubPlatforms; lib = nixpkgs.lib; forAllSystems = lib.genAttrs lib.systems.flakeExposed; forGithubSystems = lib.genAttrs githubSystems; From be7b9fcda928795bdd983b631657fd5120712229 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:09:34 +0330 Subject: [PATCH 11/25] Nix: remove duplicate systems from CI --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3f3216f85..3caa97787 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ }); githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = forGithubSystems (system: self.packages.${system}); + checks = forGithubSystems (system: self.packages.${system}.pcsx-redux); }; }; } From 81cd931be0e30f8adb78e8718714700c54a4337c Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:12:40 +0330 Subject: [PATCH 12/25] Nix: remove duplicate systems from CI --- flake.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 3caa97787..c249c2731 100644 --- a/flake.nix +++ b/flake.nix @@ -22,11 +22,12 @@ let pkgs = import nixpkgs { inherit system; }; in { pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { src = self; }; - default = self.packages.${system}.pcsx-redux; + # default gets duplicated in githubActions + # default = self.packages.${system}.pcsx-redux; }); githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = forGithubSystems (system: self.packages.${system}.pcsx-redux); + checks = forGithubSystems (system: self.packages.${system}.packages); }; }; } From 9281a15608bfa158ed502d70b423ec34903d2937 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:13:56 +0330 Subject: [PATCH 13/25] Nix: fix github actions --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c249c2731..e9ee347e9 100644 --- a/flake.nix +++ b/flake.nix @@ -27,7 +27,7 @@ }); githubActions = nix-github-actions.lib.mkGithubMatrix { - checks = forGithubSystems (system: self.packages.${system}.packages); + checks = forGithubSystems (system: self.packages.${system}); }; }; } From cfb9ea58f34a4fb7751c282f7ac36daa547777d6 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:20:52 +0330 Subject: [PATCH 14/25] Nix: Update package metadata --- flake.nix | 5 ++++- pcsx-redux.nix | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index e9ee347e9..aacbcd3d4 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,10 @@ packages = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; in { - pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { src = self; }; + pcsx-redux = pkgs.callPackage ./pcsx-redux.nix { + src = self; + platforms = lib.systems.flakeExposed; + }; # default gets duplicated in githubActions # default = self.packages.${system}.pcsx-redux; }); diff --git a/pcsx-redux.nix b/pcsx-redux.nix index 7cf973e55..5aaaa56b2 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -28,8 +28,9 @@ ucl, llhttp, + src, debugBuild ? false, - src + platforms, }: let # get rid of this nonsense @@ -197,9 +198,9 @@ in stdenv.mkDerivation { meta = { homepage = "https://pcsx-redux.consoledev.net"; description = "PlayStation 1 emulator and debugger"; - #license = lib.licenses.gpl3Only; + #license = lib.licenses.; mainProgram = "pcsx-redux"; - #maintainers = with lib.maintainers; [ guibou AndersonTorres ]; - platforms = lib.platforms.linux; + #maintainers = with lib.maintainers; []; + inherit platforms; }; } From 72ebd24c275edbc33da2967b75acce528137ea64 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:29:54 +0330 Subject: [PATCH 15/25] Nix: Remove aarch64 for now --- flake.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index aacbcd3d4..5e381042a 100644 --- a/flake.nix +++ b/flake.nix @@ -13,10 +13,15 @@ nix-github-actions }: let - githubSystems = builtins.attrNames nix-github-actions.lib.githubPlatforms; lib = nixpkgs.lib; - forAllSystems = lib.genAttrs lib.systems.flakeExposed; - forGithubSystems = lib.genAttrs githubSystems; + # githubSystems = builtins.attrNames nix-github-actions.lib.githubPlatforms; + # forAllSystems = lib.genAttrs lib.systems.flakeExposed; + # forGithubSystems = lib.genAttrs githubSystems; + # TODO: githubSystems should be supportedSystems intersects lib.githubPlatforms + # Some of the dependencies don't build on aarch64. Will fix later + supportedSystems = [ "x86_64-linux" "x86_64-darwin" ]; + forAllSystems = lib.genAttrs supportedSystems; + forGithubSystems = lib.genAttrs supportedSystems; in { packages = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; @@ -25,7 +30,7 @@ src = self; platforms = lib.systems.flakeExposed; }; - # default gets duplicated in githubActions + # FIXME: default gets duplicated in githubActions # default = self.packages.${system}.pcsx-redux; }); From ee6af1e0f6322c20d1ab156b3b91e34961658ee0 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:35:01 +0330 Subject: [PATCH 16/25] Nix: actually darwin is the problem --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 5e381042a..6373fdff5 100644 --- a/flake.nix +++ b/flake.nix @@ -18,8 +18,8 @@ # forAllSystems = lib.genAttrs lib.systems.flakeExposed; # forGithubSystems = lib.genAttrs githubSystems; # TODO: githubSystems should be supportedSystems intersects lib.githubPlatforms - # Some of the dependencies don't build on aarch64. Will fix later - supportedSystems = [ "x86_64-linux" "x86_64-darwin" ]; + # Some of the dependencies don't build on clang. Will fix later + supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; forAllSystems = lib.genAttrs supportedSystems; forGithubSystems = lib.genAttrs supportedSystems; in { From ace67459040475b71ac08df535980335de88a983 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 17:50:26 +0330 Subject: [PATCH 17/25] Nix: actually it's both --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 6373fdff5..f12fda3b1 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,8 @@ # forGithubSystems = lib.genAttrs githubSystems; # TODO: githubSystems should be supportedSystems intersects lib.githubPlatforms # Some of the dependencies don't build on clang. Will fix later - supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; + # vixl won't build on aarch64. Something to do with the include paths + supportedSystems = [ "x86_64-linux" ]; forAllSystems = lib.genAttrs supportedSystems; forGithubSystems = lib.genAttrs supportedSystems; in { From 1317919489b4f9c05622ea24434cca200a35ce8a Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 18:01:56 +0330 Subject: [PATCH 18/25] Nix: Add vixl dep --- flake.nix | 3 +-- pcsx-redux.nix | 13 +++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index f12fda3b1..6373fdff5 100644 --- a/flake.nix +++ b/flake.nix @@ -19,8 +19,7 @@ # forGithubSystems = lib.genAttrs githubSystems; # TODO: githubSystems should be supportedSystems intersects lib.githubPlatforms # Some of the dependencies don't build on clang. Will fix later - # vixl won't build on aarch64. Something to do with the include paths - supportedSystems = [ "x86_64-linux" ]; + supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; forAllSystems = lib.genAttrs supportedSystems; forGithubSystems = lib.genAttrs supportedSystems; in { diff --git a/pcsx-redux.nix b/pcsx-redux.nix index 5aaaa56b2..aaafc7288 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -12,7 +12,6 @@ libX11, pkg-config, imagemagick, - # luajit, luajitPackages, multipart-parser-c, fmt, @@ -52,6 +51,12 @@ let rev = "7c021819bbd4843a1a3091fe47346d3fcb2a3e1a"; hash = "sha256-gZHbNuDkLXlLlXZZpLBHcbwzTfeBBkLY7xl4L5yr2lY="; }; + vixl = fetchFromGitHub { + owner = "grumpycoders"; + repo = "vixl"; + rev = "53ad192b26ddf6edd228a24ae1cffc363b442c01"; + hash = "sha256-p9Z2lFzhqnHnFWfqT6BIJBVw2ZpkVIxykhG3jUHXA84="; + }; imgui-md = fetchFromGitHub { owner = "mekhontsev"; repo = "imgui_md"; @@ -139,7 +144,11 @@ in stdenv.mkDerivation { chmod -R +w source/third_party/SDL_GameControllerDB chmod -R +w source/third_party/tracy chmod -R +w source/third_party/luajit - ''; + '' + + lib.optionalString stdenv.hostPlatform.isAarch '' + cp -r ${vixl.out} source/third_party/vixl + chmod -R +w source/third_party/vixl + ''; patches = [ ./001-patch.diff From 6cbcb5fe0b0c24f7156f7749b453123dd1532dca Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 18:30:16 +0330 Subject: [PATCH 19/25] Nix: Update flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 4c8c8a0d7..a416a730e 100644 --- a/flake.lock +++ b/flake.lock @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1733940404, - "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", + "lastModified": 1739020877, + "narHash": "sha256-mIvECo/NNdJJ/bXjNqIh8yeoSjVLAuDuTUzAo7dzs8Y=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", + "rev": "a79cfe0ebd24952b580b1cf08cd906354996d547", "type": "github" }, "original": { From a44cbe65556d5ac212693168359bd20548873ea1 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 19:06:58 +0330 Subject: [PATCH 20/25] Nix: Fix metadata, cleanup --- flake.nix | 2 +- pcsx-redux.nix | 32 -------------------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/flake.nix b/flake.nix index 6373fdff5..ff3079aeb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = ""; + description = "PlayStation 1 emulator and debugger"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; diff --git a/pcsx-redux.nix b/pcsx-redux.nix index aaafc7288..f9fa3e615 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -32,7 +32,6 @@ platforms, }: let -# get rid of this nonsense zep = fetchFromGitHub { owner = "grumpycoders"; repo = "zep"; @@ -93,35 +92,12 @@ let rev = "b1e342774cbb35467dfdd3634d4f0181a76cbc89"; hash = "sha256-LYvO+chDVo6D++fuFbxqSRltGW3y82SESmtFj39TdSA="; }; - # commit = "faee80688fa03d924437118b28720184b7b58de1"; in stdenv.mkDerivation { pname = "pcsx-redux"; version = "0.99test"; inherit src; -/* - src = fetchFromGitHub { - owner = "grumpycoders"; - # owner = "NotExactlySiev"; - repo = "pcsx-redux"; - rev = commit; - hash = "sha256-qbpeNCv7jsRBg7GOn/EAm1A2K3F/zHuMHF/bBOb9q0o="; - }; -*/ postUnpack = '' - # rmdir source/third_party/miniaudio - # rmdir source/third_party/zep - # rmdir source/third_party/nanosvg - # rmdir source/third_party/nanovg - # rmdir source/third_party/imgui - # rmdir source/third_party/imgui_md - # rmdir source/third_party/xbyak - # rmdir source/third_party/luafilesystem - # rmdir source/third_party/luv - # rmdir source/third_party/SDL_GameControllerDB - # rmdir source/third_party/tracy - # rmdir source/third_party/luajit - cp -r ${miniaudio.out} source/third_party/miniaudio cp -r ${zep.out} source/third_party/zep cp -r ${nanosvg.out} source/third_party/nanosvg @@ -162,12 +138,7 @@ in stdenv.mkDerivation { buildInputs = [ stb ucl - #imgui md4c - # luajit - # luajitPackages.lpeg - #luajitPackages.luafilesystem - #luajitPackages.lua-protobuf luajitPackages.libluv multipart-parser-c fmt @@ -201,15 +172,12 @@ in stdenv.mkDerivation { enableDebugging = debugBuild; enableParallelBuilding = true; - # NIX_BUILD_CORES = 10; NIX_BUILD_CORES = 2; meta = { homepage = "https://pcsx-redux.consoledev.net"; description = "PlayStation 1 emulator and debugger"; - #license = lib.licenses.; mainProgram = "pcsx-redux"; - #maintainers = with lib.maintainers; []; inherit platforms; }; } From 914a939dab9b73d58ddac59b0c905051f5e85f7c Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 19:09:49 +0330 Subject: [PATCH 21/25] Nix: Adjust patch --- 001-patch.diff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/001-patch.diff b/001-patch.diff index ce7c09a80..71a830d4b 100644 --- a/001-patch.diff +++ b/001-patch.diff @@ -30,7 +30,7 @@ index 3edc8c93..54cf8c37 100644 -CPPFLAGS += -Ithird_party/luv/deps/lua-compat-5.3/c-api CPPFLAGS += -Ithird_party/magic_enum/include/magic_enum -CPPFLAGS += -Ithird_party/md4c/src - CPPFLAGS += -Ithird_party/multipart-parser-c +-CPPFLAGS += -Ithird_party/multipart-parser-c CPPFLAGS += -Ithird_party/tracy/public -CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include -CPPFLAGS += -Ithird_party/uriparser/include @@ -68,7 +68,7 @@ index 3edc8c93..54cf8c37 100644 SRCS += third_party/nanovg/src/nanovg.c -SRCS += third_party/tracy/public/TracyClient.cpp -SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c - SRCS += $(wildcard third_party/uriparser/src/*.c) +-SRCS += $(wildcard third_party/uriparser/src/*.c) SRCS += third_party/zep/extensions/repl/mode_repl.cpp SRCS += $(wildcard third_party/zep/src/*.cpp) @@ -167,8 +154,6 @@ ifeq ($(CROSS),arm64) From 73679f89597f356c5473a474b32c1b42d2175467 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 19:17:07 +0330 Subject: [PATCH 22/25] Nix: Fix patch --- 001-patch.diff | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/001-patch.diff b/001-patch.diff index 71a830d4b..e9daa9388 100644 --- a/001-patch.diff +++ b/001-patch.diff @@ -1,5 +1,5 @@ diff --git a/Makefile b/Makefile -index 3edc8c93..54cf8c37 100644 +index 553b99a2..f9f51921 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ UNAME_M := $(shell uname -m) @@ -20,7 +20,7 @@ index 3edc8c93..54cf8c37 100644 CPPFLAGS += -Ithird_party/gl3w CPPFLAGS += -Ithird_party/googletest/googletest/include CPPFLAGS += -Ithird_party/imgui -@@ -32,16 +30,10 @@ CPPFLAGS += -Ithird_party/imgui/backends +@@ -32,16 +30,9 @@ CPPFLAGS += -Ithird_party/imgui/backends CPPFLAGS += -Ithird_party/imgui/examples CPPFLAGS += -Ithird_party/imgui/misc/cpp CPPFLAGS += -Ithird_party/libelfin @@ -37,7 +37,7 @@ index 3edc8c93..54cf8c37 100644 CPPFLAGS += -Ithird_party/zep/extensions CPPFLAGS += -Ithird_party/zep/include CPPFLAGS += -Ithird_party/xbyak/xbyak -@@ -86,6 +78,8 @@ else +@@ -86,6 +77,8 @@ else endif LDFLAGS += third_party/luajit/src/libluajit.a @@ -46,7 +46,7 @@ index 3edc8c93..54cf8c37 100644 LDFLAGS += -ldl LDFLAGS += -g -@@ -109,7 +103,6 @@ endif +@@ -109,7 +102,6 @@ endif LD := $(CXX) SRCS := $(call rwildcard,src/,*.cc) @@ -54,7 +54,7 @@ index 3edc8c93..54cf8c37 100644 IMGUI_SRCS += $(wildcard third_party/imgui/*.cpp) VIXL_SRCS := $(call rwildcard, third_party/vixl/src,*.cc) SRCS += $(IMGUI_SRCS) -@@ -129,16 +122,10 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp +@@ -129,17 +121,10 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp SRCS += third_party/imgui_md/imgui_md.cpp SRCS += third_party/imgui_memory_editor/imgui_memory_editor.cpp @@ -71,7 +71,8 @@ index 3edc8c93..54cf8c37 100644 -SRCS += $(wildcard third_party/uriparser/src/*.c) SRCS += third_party/zep/extensions/repl/mode_repl.cpp SRCS += $(wildcard third_party/zep/src/*.cpp) -@@ -167,8 +154,6 @@ ifeq ($(CROSS),arm64) + SRCS += third_party/zep/src/mcommon/animation/timer.cpp +@@ -167,8 +152,6 @@ ifeq ($(CROSS),arm64) endif SUPPORT_SRCS := src/support/file.cc src/support/mem4g.cc src/support/zfile.cc SUPPORT_SRCS += src/supportpsx/adpcm.cc src/supportpsx/binloader.cc src/supportpsx/ps1-packer.cc From 6f12a248cc67256377d3be76daf05fe9dc1676b8 Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Tue, 11 Feb 2025 22:50:17 +0330 Subject: [PATCH 23/25] Nix: Re-enable Lua --- 001-patch.diff | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/001-patch.diff b/001-patch.diff index e9daa9388..104a017c1 100644 --- a/001-patch.diff +++ b/001-patch.diff @@ -81,21 +81,3 @@ index 553b99a2..f9f51921 100644 SUPPORT_SRCS += $(wildcard third_party/iec-60908b/*.c) OBJECTS := third_party/luajit/src/libluajit.a -diff --git a/src/main/main.cc b/src/main/main.cc -index 850617ee..cecc64f4 100644 ---- a/src/main/main.cc -+++ b/src/main/main.cc -@@ -364,11 +364,12 @@ runner.init({ - luacovEnabled = false; - } - } -+/* - emulator->setLua(); - s_ui->setLua(*emulator->m_lua); - emulator->m_spu->setLua(*emulator->m_lua); - assert(emulator->m_lua->gettop() == 0); -- -+*/ - // Starting up the whole emulator; we delay setting the GPU only now because why not. - auto &emuSettings = emulator->settings; - emulator->m_spu->open(); From 0dae74e4dbfa00bc02effde024d2b46b8be523be Mon Sep 17 00:00:00 2001 From: NotExactlySiev Date: Wed, 12 Feb 2025 04:45:31 +0330 Subject: [PATCH 24/25] Nix: Remove the thirdparty directories that we replace --- pcsx-redux.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pcsx-redux.nix b/pcsx-redux.nix index f9fa3e615..b80ab6e35 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -98,6 +98,18 @@ in stdenv.mkDerivation { inherit src; postUnpack = '' + rm -rf source/third_party/miniaudio + rm -rf source/third_party/zep + rm -rf source/third_party/nanosvg + rm -rf source/third_party/nanovg + rm -rf source/third_party/imgui + rm -rf source/third_party/imgui_md + rm -rf source/third_party/xbyak + rm -rf source/third_party/luafilesystem + rm -rf source/third_party/SDL_GameControllerDB + rm -rf source/third_party/tracy + rm -rf source/third_party/luajit + cp -r ${miniaudio.out} source/third_party/miniaudio cp -r ${zep.out} source/third_party/zep cp -r ${nanosvg.out} source/third_party/nanosvg From ccc44930f6dcd5f4314ff147cf45bf0fe1694ca7 Mon Sep 17 00:00:00 2001 From: Nicolas 'Pixel' Noble Date: Tue, 11 Feb 2025 20:45:42 -0800 Subject: [PATCH 25/25] Removing patch. --- .../workflows/cachix-install-nix-action.yml | 3 + 001-patch.diff | 83 ------------------- Makefile | 71 +++++++++++----- pcsx-redux.nix | 8 -- 4 files changed, 54 insertions(+), 111 deletions(-) delete mode 100644 001-patch.diff diff --git a/.github/workflows/cachix-install-nix-action.yml b/.github/workflows/cachix-install-nix-action.yml index 91d9b27eb..daa6d5cdc 100644 --- a/.github/workflows/cachix-install-nix-action.yml +++ b/.github/workflows/cachix-install-nix-action.yml @@ -27,5 +27,8 @@ jobs: matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} steps: - uses: actions/checkout@v4 + - uses: n1hility/cancel-previous-runs@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} - uses: cachix/install-nix-action@v30 - run: nix build -L '.#${{ matrix.attr }}' diff --git a/001-patch.diff b/001-patch.diff deleted file mode 100644 index 104a017c1..000000000 --- a/001-patch.diff +++ /dev/null @@ -1,83 +0,0 @@ -diff --git a/Makefile b/Makefile -index 553b99a2..f9f51921 100644 ---- a/Makefile -+++ b/Makefile -@@ -8,7 +8,7 @@ UNAME_M := $(shell uname -m) - rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) - CC_IS_CLANG := $(shell $(CC) --version | grep -q clang && echo true || echo false) - --PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib libcurl -+PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib libcurl fmt md4c libluv liburiparser libllhttp - - LOCALES := el es_ES fr ja pt_BR uk zh_CN - -@@ -23,8 +23,6 @@ CPPFLAGS += `pkg-config --cflags $(PACKAGES)` - CPPFLAGS += -I. - CPPFLAGS += -Isrc - CPPFLAGS += -Ithird_party --CPPFLAGS += -Ithird_party/ELFIO --CPPFLAGS += -Ithird_party/fmt/include/ - CPPFLAGS += -Ithird_party/gl3w - CPPFLAGS += -Ithird_party/googletest/googletest/include - CPPFLAGS += -Ithird_party/imgui -@@ -32,16 +30,9 @@ CPPFLAGS += -Ithird_party/imgui/backends - CPPFLAGS += -Ithird_party/imgui/examples - CPPFLAGS += -Ithird_party/imgui/misc/cpp - CPPFLAGS += -Ithird_party/libelfin --CPPFLAGS += -Ithird_party/llhttp - CPPFLAGS += -Ithird_party/luajit/src --CPPFLAGS += -Ithird_party/luv/src --CPPFLAGS += -Ithird_party/luv/deps/lua-compat-5.3/c-api - CPPFLAGS += -Ithird_party/magic_enum/include/magic_enum --CPPFLAGS += -Ithird_party/md4c/src --CPPFLAGS += -Ithird_party/multipart-parser-c - CPPFLAGS += -Ithird_party/tracy/public --CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include --CPPFLAGS += -Ithird_party/uriparser/include - CPPFLAGS += -Ithird_party/zep/extensions - CPPFLAGS += -Ithird_party/zep/include - CPPFLAGS += -Ithird_party/xbyak/xbyak -@@ -86,6 +77,8 @@ else - endif - - LDFLAGS += third_party/luajit/src/libluajit.a -+LDFLAGS += -lucl -+LDFLAGS += -lmultipart - LDFLAGS += -ldl - LDFLAGS += -g - -@@ -109,7 +102,6 @@ endif - LD := $(CXX) - - SRCS := $(call rwildcard,src/,*.cc) --SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc - IMGUI_SRCS += $(wildcard third_party/imgui/*.cpp) - VIXL_SRCS := $(call rwildcard, third_party/vixl/src,*.cc) - SRCS += $(IMGUI_SRCS) -@@ -129,17 +121,10 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp - SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp - SRCS += third_party/imgui_md/imgui_md.cpp - SRCS += third_party/imgui_memory_editor/imgui_memory_editor.cpp --SRCS += $(wildcard third_party/llhttp/*.c) - SRCS += $(wildcard third_party/lpeg/*.c) - SRCS += third_party/lua-protobuf/pb.c - SRCS += third_party/luafilesystem/src/lfs.c --SRCS += third_party/luv/src/luv.c --SRCS += third_party/md4c/src/md4c.c --SRCS += third_party/multipart-parser-c/multipart_parser.c - SRCS += third_party/nanovg/src/nanovg.c --SRCS += third_party/tracy/public/TracyClient.cpp --SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c --SRCS += $(wildcard third_party/uriparser/src/*.c) - SRCS += third_party/zep/extensions/repl/mode_repl.cpp - SRCS += $(wildcard third_party/zep/src/*.cpp) - SRCS += third_party/zep/src/mcommon/animation/timer.cpp -@@ -167,8 +152,6 @@ ifeq ($(CROSS),arm64) - endif - SUPPORT_SRCS := src/support/file.cc src/support/mem4g.cc src/support/zfile.cc - SUPPORT_SRCS += src/supportpsx/adpcm.cc src/supportpsx/binloader.cc src/supportpsx/ps1-packer.cc --SUPPORT_SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc --SUPPORT_SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c - SUPPORT_SRCS += $(wildcard third_party/iec-60908b/*.c) - OBJECTS := third_party/luajit/src/libluajit.a - diff --git a/Makefile b/Makefile index 553b99a24..be1a87291 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,12 @@ CROSS ?= none UNAME_S := $(shell uname -s) UNAME_M := $(shell uname -m) -rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) +rwildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) CC_IS_CLANG := $(shell $(CC) --version | grep -q clang && echo true || echo false) -PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib libcurl +PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libcurl libuv zlib +OPTIONAL_PACKAGES := md4c fmt libllhttp libluv liburiparser +OPTIONAL_LIBRARIES := multipart ucl LOCALES := el es_ES fr ja pt_BR uk zh_CN @@ -19,12 +21,11 @@ HAS_SUBMODULES = true endif CXXFLAGS += -std=c++2b -CPPFLAGS += `pkg-config --cflags $(PACKAGES)` CPPFLAGS += -I. CPPFLAGS += -Isrc CPPFLAGS += -Ithird_party CPPFLAGS += -Ithird_party/ELFIO -CPPFLAGS += -Ithird_party/fmt/include/ +CPPFLAGS_pkg_fmt += -Ithird_party/fmt/include/ CPPFLAGS += -Ithird_party/gl3w CPPFLAGS += -Ithird_party/googletest/googletest/include CPPFLAGS += -Ithird_party/imgui @@ -32,16 +33,16 @@ CPPFLAGS += -Ithird_party/imgui/backends CPPFLAGS += -Ithird_party/imgui/examples CPPFLAGS += -Ithird_party/imgui/misc/cpp CPPFLAGS += -Ithird_party/libelfin -CPPFLAGS += -Ithird_party/llhttp +CPPFLAGS_pkg_libllhttp += -Ithird_party/llhttp CPPFLAGS += -Ithird_party/luajit/src -CPPFLAGS += -Ithird_party/luv/src -CPPFLAGS += -Ithird_party/luv/deps/lua-compat-5.3/c-api +CPPFLAGS_pkg_libluv += -Ithird_party/luv/src +CPPFLAGS_pkg_libluv += -Ithird_party/luv/deps/lua-compat-5.3/c-api CPPFLAGS += -Ithird_party/magic_enum/include/magic_enum -CPPFLAGS += -Ithird_party/md4c/src -CPPFLAGS += -Ithird_party/multipart-parser-c +CPPFLAGS_pkg_md4c += -Ithird_party/md4c/src +CPPFLAGS_lib_multipart += -Ithird_party/multipart-parser-c CPPFLAGS += -Ithird_party/tracy/public -CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include -CPPFLAGS += -Ithird_party/uriparser/include +CPPFLAGS_lib_ucl += -Ithird_party/ucl -Ithird_party/ucl/include +CPPFLAGS_pkg_liburiparser += -Ithird_party/uriparser/include CPPFLAGS += -Ithird_party/zep/extensions CPPFLAGS += -Ithird_party/zep/include CPPFLAGS += -Ithird_party/xbyak/xbyak @@ -75,7 +76,6 @@ ifeq ($(UNAME_S),Darwin) endif LUAJIT_LDFLAGS := $(LDFLAGS) -LDFLAGS += `pkg-config --libs $(PACKAGES)` ifeq ($(UNAME_S),Darwin) LDFLAGS += -lc++ -framework GLUT -framework OpenGL -framework CoreFoundation -framework Cocoa @@ -108,8 +108,8 @@ endif LD := $(CXX) -SRCS := $(call rwildcard,src/,*.cc) -SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc +SRCS += $(call rwildcard,src/,*.cc) +SRCS_pkg_fmt += third_party/fmt/src/os.cc third_party/fmt/src/format.cc IMGUI_SRCS += $(wildcard third_party/imgui/*.cpp) VIXL_SRCS := $(call rwildcard, third_party/vixl/src,*.cc) SRCS += $(IMGUI_SRCS) @@ -129,16 +129,16 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp SRCS += third_party/imgui_md/imgui_md.cpp SRCS += third_party/imgui_memory_editor/imgui_memory_editor.cpp -SRCS += $(wildcard third_party/llhttp/*.c) +SRCS_pkg_libllhttp += $(wildcard third_party/llhttp/*.c) SRCS += $(wildcard third_party/lpeg/*.c) SRCS += third_party/lua-protobuf/pb.c SRCS += third_party/luafilesystem/src/lfs.c -SRCS += third_party/luv/src/luv.c -SRCS += third_party/md4c/src/md4c.c -SRCS += third_party/multipart-parser-c/multipart_parser.c +SRCS_pkg_libluv += third_party/luv/src/luv.c +SRCS_pkg_md4c += third_party/md4c/src/md4c.c +SRCS_lib_multipart += third_party/multipart-parser-c/multipart_parser.c SRCS += third_party/nanovg/src/nanovg.c -SRCS += third_party/tracy/public/TracyClient.cpp -SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c +SRCS_ReleaseWithTracy += third_party/tracy/public/TracyClient.cpp +SRCS_lib_ucl += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c SRCS += $(wildcard third_party/uriparser/src/*.c) SRCS += third_party/zep/extensions/repl/mode_repl.cpp SRCS += $(wildcard third_party/zep/src/*.cpp) @@ -176,6 +176,37 @@ TOOLS = exe2elf exe2iso modconv ps1-packer psyq-obj-parser ############################################################################## +SRCS += $(SRCS_$(BUILD)) + +define CHECK_PKG +ifeq ($(shell pkg-config --exists $(1) && echo true || echo false),true) +PACKAGES += $(1) +else +CPPFLAGS += $(CPPFLAGS_pkg_$(1)) +LDFLAGS += $(LDFLAGS_pkg_$(1)) +SRCS += $(SRCS_pkg_$(1)) +endif +endef + +define CHECK_LIB +ifeq ($(shell echo "int main(){}" | gcc -x c - -l$(1) -Wl,--no-as-needed -Wl,--unresolved-symbols=ignore-all -Wl,--no-undefined -o /dev/null >& /dev/null && echo true || echo false),true) +LDFLAGS += -l$(1) +else +CPPFLAGS += $(CPPFLAGS_lib_$(1)) +LDFLAGS += $(LDFLAGS_lib_$(1)) +SRCS += $(SRCS_lib_$(1)) +endif +endef + +$(foreach pkg,$(OPTIONAL_PACKAGES),$(eval $(call CHECK_PKG,$(pkg)))) +$(foreach lib,$(OPTIONAL_LIBRARIES),$(eval $(call CHECK_LIB,$(lib)))) + +CPPFLAGS_PKGCONFIG := $(shell pkg-config --cflags $(PACKAGES)) +LDFLAGS_PKGCONFIG := $(shell pkg-config --libs $(PACKAGES)) + +CPPFLAGS += $(CPPFLAGS_PKGCONFIG) +LDFLAGS += $(LDFLAGS_PKGCONFIG) + OBJECTS += $(patsubst %.c,%.o,$(filter %.c,$(SRCS))) OBJECTS += $(patsubst %.cc,%.o,$(filter %.cc,$(SRCS))) OBJECTS += $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCS))) diff --git a/pcsx-redux.nix b/pcsx-redux.nix index b80ab6e35..cea4fb521 100644 --- a/pcsx-redux.nix +++ b/pcsx-redux.nix @@ -138,10 +138,6 @@ in stdenv.mkDerivation { chmod -R +w source/third_party/vixl ''; - patches = [ - ./001-patch.diff - ]; - nativeBuildInputs = [ pkg-config imagemagick @@ -171,10 +167,6 @@ in stdenv.mkDerivation { llhttp ]; - runtimeDependencies = [ - # zlib - ]; - makeFlags = [ "DESTDIR=$(out)" ];