From b1a81b82aa6bbe3668383d5c145a3e31d3999929 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Sun, 18 May 2025 13:07:55 +0200 Subject: [PATCH 1/2] x16: fix build on GCC 14 --- pkgs/by-name/x1/x16/package.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/by-name/x1/x16/package.nix b/pkgs/by-name/x1/x16/package.nix index a5433fa475f6..d13631962019 100644 --- a/pkgs/by-name/x1/x16/package.nix +++ b/pkgs/by-name/x1/x16/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitHub, + fetchpatch2, SDL2, callPackage, zlib, @@ -18,6 +19,15 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-E4TosRoORCWLotOIXROP9oqwqo1IRSa6X13GnmuxE9A="; }; + # Fix build on GCC 14 + # TODO: Remove for next release as it should already be included in upstream + patches = [ + (fetchpatch2 { + url = "https://github.com/X16Community/x16-emulator/commit/3da83c93d46a99635cf73a6f9fdcf1bd4a4ae04f.patch"; + hash = "sha256-DZItqq7B1lXZ6VFsQUdQKn0wt1HaX4ymq2pI2DamY3w="; + }) + ]; + postPatch = '' substituteInPlace Makefile \ --replace-fail '/bin/echo' 'echo' From 0405671c7bb0e6296e670ecf4fdadda88f1d6153 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Sun, 18 May 2025 13:07:55 +0200 Subject: [PATCH 2/2] x16: adopt & modernize --- pkgs/by-name/x1/x16/package.nix | 9 ++++++--- pkgs/by-name/x1/x16/rom.nix | 6 ++++-- pkgs/by-name/x1/x16/run.nix | 18 +++++------------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/pkgs/by-name/x1/x16/package.nix b/pkgs/by-name/x1/x16/package.nix index d13631962019..27cc806728b0 100644 --- a/pkgs/by-name/x1/x16/package.nix +++ b/pkgs/by-name/x1/x16/package.nix @@ -6,6 +6,7 @@ SDL2, callPackage, zlib, + nix-update-script, }: stdenv.mkDerivation (finalAttrs: { @@ -15,7 +16,7 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "X16Community"; repo = "x16-emulator"; - rev = "r${finalAttrs.version}"; + tag = "r${finalAttrs.version}"; hash = "sha256-E4TosRoORCWLotOIXROP9oqwqo1IRSa6X13GnmuxE9A="; }; @@ -58,14 +59,16 @@ stdenv.mkDerivation (finalAttrs: { run = (callPackage ./run.nix { }) { inherit (finalAttrs.finalPackage) emulator rom; }; + + updateScript = nix-update-script { }; }; meta = { homepage = "https://cx16forum.com/"; description = "Official emulator of CommanderX16 8-bit computer"; - changelog = "https://github.com/X16Community/x16-emulator/blob/r${finalAttrs.version}/RELEASES.md"; + changelog = "https://github.com/X16Community/x16-emulator/blob/${finalAttrs.src.rev}/RELEASES.md"; license = lib.licenses.bsd2; - maintainers = with lib.maintainers; [ ]; + maintainers = with lib.maintainers; [ pluiedev ]; mainProgram = "x16emu"; inherit (SDL2.meta) platforms; broken = stdenv.hostPlatform.isAarch64; # ofborg fails to compile it diff --git a/pkgs/by-name/x1/x16/rom.nix b/pkgs/by-name/x1/x16/rom.nix index 7102b3199687..2738c0378e4b 100644 --- a/pkgs/by-name/x1/x16/rom.nix +++ b/pkgs/by-name/x1/x16/rom.nix @@ -5,6 +5,7 @@ cc65, lzsa, python3, + nix-update-script, }: stdenv.mkDerivation (finalAttrs: { @@ -27,7 +28,7 @@ stdenv.mkDerivation (finalAttrs: { postPatch = '' patchShebangs findsymbols scripts/ substituteInPlace Makefile \ - --replace-fail '/bin/echo' 'echo' + --replace-fail '/bin/echo' 'echo' ''; dontConfigure = true; @@ -47,13 +48,14 @@ stdenv.mkDerivation (finalAttrs: { # upstream project recommends emulator and rom to be synchronized; passing # through the version is useful to ensure this inherit (finalAttrs) version; + updateScript = nix-update-script { }; }; meta = { homepage = "https://github.com/X16Community/x16-rom"; description = "ROM file for CommanderX16 8-bit computer"; license = lib.licenses.bsd2; - maintainers = with lib.maintainers; [ ]; + maintainers = with lib.maintainers; [ pluiedev ]; inherit (cc65.meta) platforms; broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64; }; diff --git a/pkgs/by-name/x1/x16/run.nix b/pkgs/by-name/x1/x16/run.nix index db5d531fc2e3..72c746533ac2 100644 --- a/pkgs/by-name/x1/x16/run.nix +++ b/pkgs/by-name/x1/x16/run.nix @@ -1,7 +1,7 @@ { runtimeShell, symlinkJoin, - writeTextFile, + writeShellScriptBin, }: { emulator, rom }: @@ -9,18 +9,10 @@ assert emulator.version == rom.version; let - runScript = writeTextFile { - name = "run-x16"; - text = '' - #!${runtimeShell} - - defaultRom="${rom}/share/x16-rom/rom.bin" - - exec "${emulator}/bin/x16emu" -rom $defaultRom "$@" - ''; - executable = true; - destination = "/bin/run-x16"; - }; + runScript = writeShellScriptBin "run-x16" '' + defaultRom="${rom}/share/x16-rom/rom.bin" + exec "${emulator}/bin/x16emu" -rom $defaultRom "$@" + ''; in symlinkJoin { pname = "run-x16";