generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pce: init at 0.2.2 and 0.2.2-unstable-2024-01-22
- Loading branch information
Showing
5 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
pkgs/pce/0001-Allow-referencing-PCE_DIR_DATA-in-config-files-inste.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Rhys-T <108157737+Rhys-T@users.noreply.github.com> | ||
Date: Sat, 21 Sep 2024 17:14:52 -0400 | ||
Subject: [PATCH] Allow referencing $PCE_DIR_DATA in config files instead of | ||
hardcoding it | ||
|
||
Note that this patch doesn't change the various Makefile.inc files. I'm leaving that to `postPatch` in order to handle both versions of PCE the same way. | ||
--- | ||
src/config.h.in | 1 + | ||
src/lib/path.c | 7 +++++++ | ||
2 files changed, 8 insertions(+) | ||
|
||
diff --git a/src/config.h.in b/src/config.h.in | ||
index 1f296cf0..71702f82 100644 | ||
--- a/src/config.h.in | ||
+++ b/src/config.h.in | ||
@@ -80,6 +80,7 @@ | ||
#undef PCE_HOST_PPC | ||
#undef PCE_HOST_SPARC | ||
|
||
+#undef PCE_DIR_DATA | ||
#undef PCE_DIR_ETC | ||
|
||
#undef PCE_BUILD_IBMPC | ||
diff --git a/src/lib/path.c b/src/lib/path.c | ||
index 57785ea6..8a0a4429 100644 | ||
--- a/src/lib/path.c | ||
+++ b/src/lib/path.c | ||
@@ -107,6 +107,13 @@ void pce_path_clear (void) | ||
|
||
int pce_path_add (const char *dir, int atend) | ||
{ | ||
+ if(strncmp(dir, "$PCE_DIR_DATA", 13) == 0) { | ||
+ char *expanded = pce_path_cat(PCE_DIR_DATA, dir+13); | ||
+ int result = pce_path_add(expanded, atend); | ||
+ free(expanded); | ||
+ return result; | ||
+ } | ||
+ | ||
unsigned i, n; | ||
char **tmp; | ||
char *str; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{callPackage, requireFile, fetchpatch, ...}@args: let | ||
thruArgs = removeAttrs args ["callPackage" "requireFile" "fetchpatch"]; | ||
in callPackage ./generic.nix (thruArgs // rec { | ||
version = "0.2.2"; | ||
includesUnfreeROMs = true; | ||
src = rec { | ||
name = "pce-${version}.tar.gz"; | ||
url = http://www.hampa.ch/pub/pce + "/pce-${version}.tar.gz"; | ||
hashWithROMs = "sha256-qMBWD8vwzBVMj1ASGG89OVKv29FEtBkSTAmlb5uquZk="; | ||
hashWithoutROMs = "sha256-z65BS+arlhem1Z0CN9W5S4p4M3onQNqX804kFeRonME="; | ||
}; | ||
patches = [(fetchpatch { | ||
name = "0001-68000-Add-a-missing-extern-declaration.patch"; | ||
url = http://git.hampa.ch/pce.git/patch/f9ebfc33107a10436506861601b162df98ca743e; | ||
# Fix the changes to the copyright header comment, | ||
# because otherwise the patch doesn't apply correctly. | ||
decode = "sed 's/(C) 2005-2018/(C) 2005-2009/'"; | ||
hash = "sha256-T3Fc4yHANjpE1Peh7Fipuk5rqFrSCpGK1f5HWyz/Q5g="; | ||
})]; | ||
supportsSDL2 = false; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
stdenv, stdenvNoCC, lib, requireFile, | ||
version, src, patches ? [], | ||
supportsSDL2, includesUnfreeROMs, | ||
withX11 ? false, withSDL ? if supportsSDL2 then 2 else 1, | ||
withReadline ? true, | ||
enableUnfreeROMs ? false, | ||
libX11 ? null, SDL ? null, SDL2 ? null, | ||
readline ? null, | ||
maintainers | ||
}: | ||
assert builtins.elem withSDL [false 1 2]; | ||
let | ||
withSDL1 = withSDL == 1; | ||
withSDL2 = withSDL == 2; | ||
in | ||
assert withSDL2 -> supportsSDL2; | ||
assert withSDL2 -> SDL2 != null; | ||
assert withSDL1 -> SDL != null; | ||
assert withX11 -> libX11 != null; | ||
assert withReadline -> readline != null; | ||
assert enableUnfreeROMs -> includesUnfreeROMs; | ||
let | ||
src' = if !includesUnfreeROMs then src else requireFile rec { | ||
inherit (src) name url; | ||
hash = src.hashWithROMs; | ||
message = '' | ||
Unfortunately, we cannot download file ${name} automatically. | ||
This version of PCE includes unfree ROM images in its distribution. | ||
Please add${lib.optionalString (!enableUnfreeROMs) " either"} ${url} | ||
${lib.optionalString (!enableUnfreeROMs) "or a pre-stripped version "}to the store with nix-prefetch-url. | ||
Alternatively, you may use a newer snapshot that has removed the | ||
unfree ROM images. | ||
''; | ||
}; | ||
src'' = if !(includesUnfreeROMs && !enableUnfreeROMs) then src' else stdenvNoCC.mkDerivation { | ||
name = "romless-${src'.name}"; | ||
src = src'; | ||
version_ = version; | ||
sourceRoot = "."; | ||
configurePhase = ""; | ||
buildPhase = ""; | ||
preferLocal = true; | ||
installPhase = '' | ||
tar --sort=name \ | ||
--mtime="@''${SOURCE_DATE_EPOCH}" \ | ||
--owner=0 --group=0 --numeric-owner \ | ||
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \ | ||
--exclude=contrib/rom \ | ||
-czf "$out" "pce-$version_" | ||
''; | ||
outputHash = src.hashWithoutROMs; | ||
}; | ||
in | ||
stdenv.mkDerivation { | ||
pname = "pce"; | ||
inherit version; | ||
src = src''; | ||
# The config file for PCE has to point to the ROM extension file in $out/share/pce | ||
# to make certain features work. These patches allow the config file to refer to | ||
# $PCE_DIR_DATA in the 'path' setting, instead of having to update the config file | ||
# whenever the store path changes. | ||
patches = patches ++ [./0001-Allow-referencing-PCE_DIR_DATA-in-config-files-inste.patch]; | ||
postPatch = '' | ||
for file in src/arch/*/Makefile.inc; do | ||
substituteInPlace "$file" --replace-quiet '"s]PCE_DIR_DATA]$(datadir)]g"' '"s]PCE_DIR_DATA]\$$PCE_DIR_DATA/pce]g"' | ||
done | ||
''; | ||
configureFlags = [ | ||
(lib.withFeature withX11 "x") | ||
(if supportsSDL2 then | ||
(lib.withFeatureAs (withSDL != null) "sdl" (toString withSDL)) | ||
else | ||
(lib.withFeature withSDL1 "sdl") | ||
) | ||
(lib.enableFeature withReadline "readline") | ||
]; | ||
buildInputs = lib.optional withX11 libX11 | ||
++ lib.optional withSDL1 SDL | ||
++ lib.optional withSDL2 SDL2 | ||
++ lib.optional withReadline readline | ||
; | ||
meta = { | ||
description = "PC Emulator"; | ||
longDescription = "PCE is a collection of microcomputer emulators."; | ||
license = [lib.licenses.gpl2Only] ++ lib.optional enableUnfreeROMs lib.licenses.unfree; | ||
maintainers = [maintainers.Rhys-T]; | ||
sourceProvenance = with lib.sourceTypes; [ | ||
fromSource | ||
# A couple of the emulators include 'ROM extensions' that are prebuilt. | ||
# They're machine code for real CPUs that existed, but in the context of | ||
# running them in an emulator - and because they actually _need_ to run | ||
# in the emulator - 'bytecode' seems like the closest available option. | ||
# PCE includes the source code for these, and _can_ rebuild them - I just | ||
# haven't gotten that part working under Nix yet. | ||
binaryBytecode | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{callPackage, fetchurl, lib, ...}@args: let | ||
thruArgs = removeAttrs args ["callPackage" "fetchurl"]; | ||
version = "0.2.2-unstable-2024-01-22"; | ||
version' = "20240122-5a67b2a9"; | ||
in callPackage ./generic.nix (thruArgs // rec { | ||
inherit version; | ||
includesUnfreeROMs = false; | ||
src = fetchurl { | ||
url = http://www.hampa.ch/pub/pce/pre + "/pce-${version'}/pce-${version'}.tar.gz"; | ||
hash = "sha256-9a6F2/DrjGby7f0IGOT1oEpeLuNdiedBgtVtZiiR8zQ="; | ||
}; | ||
supportsSDL2 = true; | ||
}) |