Skip to content

Instantly share code, notes, and snippets.

@al3xtjames
Last active October 26, 2024 00:02
Show Gist options
  • Save al3xtjames/27c87c36cbbd2245eb46213bf5b9f563 to your computer and use it in GitHub Desktop.
Save al3xtjames/27c87c36cbbd2245eb46213bf5b9f563 to your computer and use it in GitHub Desktop.
{ lib
, config
, stdenv
, fetchFromGitHub
, fetchurl
, fetchpatch
, boost
, cmake
, expat
, harfbuzz
, ffmpeg
, fftw
, fontconfig
, freetype
, fribidi
, glib
, hunspell
, hunspellDicts
, icu
, intltool
, libGL
, libGLU
, libX11
, libass
, libiconv
, libuchardet
, luajit
, meson
, ninja
, pcre
, pkg-config
, python3
, wrapGAppsHook
, zlib
, openalSupport ? stdenv.isDarwin
, openal
, alsaSupport ? stdenv.isLinux
, alsa-lib
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux
, libpulseaudio
, portaudioSupport ? false
, portaudio
, bestsourceSupport ? true
, bestsource
, ffmsSupport ? false
, ffms
# vapoursynth is currently broken on Darwin
, vapoursynthSupport ? !vapoursynth.meta.broken
, vapoursynth
, wxGTK
, withVendoredWX ? stdenv.isDarwin
, darwin
, enableStatic ? withVendoredWX
}:
let
boostOverride = boost.override { inherit enableStatic; };
inherit (darwin.apple_sdk.frameworks) AVFoundation AVKit AppKit Carbon Cocoa CoreFoundation CoreText IOKit Kernel OpenAL QuartzCore WebKit;
gtest = fetchurl {
url = "https://github.com/google/googletest/archive/release-1.8.1.zip";
hash = "sha256-kngnwYPQFzTMXP74Xg/z9akv/mGI4NGOkJxe/r8ooMc=";
};
gtest-wrap = fetchurl {
url = "https://wrapdb.mesonbuild.com/v1/projects/gtest/1.8.1/1/get_zip";
hash = "sha256-959f1G4JUHs/LgmlHqbrIAIO/+VDM19a7lnzDMjRWAU=";
};
wxWidgets = fetchFromGitHub {
owner = "wxWidgets";
repo = "wxWidgets";
rev = "v3.1.4";
fetchSubmodules = true;
hash = "sha256-alMg7QKi/l09ujKcYIKtwPwR47W5tqwERIN3xyvfz6k=";
postFetch = ''
patch -p 1 -d $out -i ${./wx-fix-cmake-files.patch}
'';
};
wxDeps = lib.optionals stdenv.isDarwin [
AVFoundation
AVKit
Kernel
WebKit
];
in stdenv.mkDerivation (finalAttrs:
let
versionParts = lib.splitString "-" finalAttrs.version;
revision = builtins.head versionParts;
tag = builtins.elemAt 1 versionParts;
commit = lib.lists.last versionParts;
in {
pname = "aegisub";
version = "9810-feature-dc68cae1b";
src = fetchFromGitHub {
owner = "arch1t3cht";
repo = "Aegisub";
rev = commit;
hash = "sha256-DWSqTMatk9Fjhp6HY5yg8skPLY025EZ4NyNIeI2p/08=";
};
patches = [
./fix-osx-bundle.patch
./0001-meson-Support-system-provided-bestsource.patch
];
postPatch = ''
mkdir subprojects/packagecache
ln -s "${gtest}" subprojects/packagecache/gtest-1.8.1.zip
ln -s "${gtest-wrap}" subprojects/packagecache/gtest-1.8.1-1-wrap.zip
patchShebangs tools/respack.py
substituteInPlace packages/meson.build \
--subst-var-by DICT_DIR ${hunspellDicts.en_US}/share/hunspell
''
+ lib.optionalString withVendoredWX ''
ln -s "${wxWidgets}" subprojects/wxWidgets
'';
nativeBuildInputs = [
intltool
meson
ninja
pkg-config
python3
wrapGAppsHook
]
++ (if withVendoredWX then [ cmake ] else [ wxGTK ])
;
buildInputs = [
boostOverride
expat
fftw
fontconfig
freetype
fribidi
glib
harfbuzz
hunspell
icu
libass
libiconv
libuchardet
luajit
pcre
zlib
]
++ lib.optionals stdenv.isDarwin [
AppKit
Carbon
Cocoa
CoreFoundation
CoreText
IOKit
QuartzCore
]
++ lib.optionals stdenv.isLinux [
libGL
libGLU
libX11
]
++ lib.optional alsaSupport alsa-lib
++ lib.optional openalSupport (if stdenv.isDarwin then OpenAL else openal)
++ lib.optional portaudioSupport portaudio
++ lib.optional pulseaudioSupport libpulseaudio
++ lib.optionals bestsourceSupport [ bestsource ffmpeg ]
++ lib.optional ffmsSupport ffms
++ lib.optional vapoursynthSupport vapoursynth
++ (if withVendoredWX then wxDeps else [ wxGTK ])
;
mesonFlags = [
(lib.strings.mesonEnable "alsa" alsaSupport)
(lib.strings.mesonEnable "avisynth" false)
(lib.strings.mesonEnable "bestsource" bestsourceSupport)
(lib.strings.mesonEnable "ffms2" ffmsSupport)
(lib.strings.mesonEnable "libpulse" pulseaudioSupport)
(lib.strings.mesonEnable "openal" openalSupport)
(lib.strings.mesonEnable "portaudio" portaudioSupport)
(lib.strings.mesonEnable "vapoursynth" vapoursynthSupport)
(lib.strings.mesonBool "build_osx_bundle" stdenv.isDarwin)
]
++ lib.optional enableStatic (lib.strings.mesonOption "default_library" "static")
;
postConfigure = ''
cat << EOF > git_version.h
#define BUILD_GIT_VERSION_NUMBER ${revision}
#define BUILD_GIT_VERSION_STRING "${finalAttrs.version}"
#define TAGGED_RELEASE 0
#define INSTALLER_VERSION "0.0.0"
#define RESOURCE_BASE_VERSION 0, 0, 0
EOF
build_date=$(date -d @$SOURCE_DATE_EPOCH "+%Y-%m-%d %H:%M %Z")
substitute $src/packages/osx_bundle/osx-bundle.sed.in osx-bundle.sed \
--subst-var-by BUILD_GIT_VERSION_STRING ${finalAttrs.version} \
--subst-var-by BUILD_DATE "$build_date"
'';
strictDeps = true;
postInstall = lib.optionalString stdenv.isDarwin ''
meson compile osx-bundle
mkdir -p $out/Applications
cp -r Aegisub.app $out/Applications
'';
hardeningDisable = [
"bindnow"
"relro"
];
meta = with lib; {
description = "Advanced subtitle editor; arch1t3cht's fork";
longDescription = ''
Aegisub is a free, cross-platform open source tool for creating and
modifying subtitles. Aegisub makes it quick and easy to time subtitles to
audio, and features many powerful tools for styling them, including a
built-in real-time video preview.
'';
homepage = "https://github.com/arch1t3cht/Aegisub";
downloadPage = "https://github.com/arch1t3cht/Aegisub/releases";
changelog = "https://github.com/arch1t3cht/Aegisub/releases/tag/${tag}";
# The Aegisub sources are itself BSD/ISC, but they are linked against GPL'd
# softwares - so the resulting program will be GPL
license = licenses.bsd3;
maintainers = with maintainers; [ AndersonTorres wegank ];
mainProgram = "aegisub";
platforms = platforms.unix;
};
})
{
lib,
stdenv,
fetchFromGitHub,
meson,
ninja,
pkg-config,
ffmpeg_6,
xxHash,
vapoursynthSupport ? !vapoursynth.meta.broken,
vapoursynth,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "bestsource";
version = "8";
src = fetchFromGitHub {
owner = "vapoursynth";
repo = "bestsource";
rev = "R${finalAttrs.version}";
hash = "sha256-O5vStHhUMTc31GyDVmiT/EfNKZgs/bxiFdZjd57RBJ4=";
fetchSubmodules = true;
};
strictDeps = true;
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs = [
ffmpeg_6
xxHash
] ++ lib.optionals vapoursynthSupport [ vapoursynth ];
mesonFlags = [ (lib.strings.mesonBool "enable_plugin" vapoursynthSupport) ];
postPatch = ''
substituteInPlace meson.build --replace-fail \
"vapoursynth_dep.get_variable(pkgconfig: 'libdir')" \
"get_option('libdir')"
'';
meta = with lib; {
description = "Super great audio/video source and FFmpeg wrapper";
longDescription = ''
BestSource (abbreviated as BS) is a cross-platform wrapper library around
FFmpeg that ensures sample/frame accurate access to audio and video by
always linearly decoding the input files.
'';
homepage = "https://github.com/vapoursynth/bestsource";
downloadPage = "https://github.com/vapoursynth/bestsource/releases";
changelog = "https://github.com/vapoursynth/bestsource/releases/tag/${finalAttrs.version}";
license = licenses.mit;
maintainers = with maintainers; [ ];
platforms = platforms.all;
};
})
diff --git a/packages/meson.build b/packages/meson.build
index 98d22d483..45d55fafa 100644
--- a/packages/meson.build
+++ b/packages/meson.build
@@ -10,7 +10,7 @@ elif host_machine.system() == 'darwin'
fontconfig_conf = run_command('pkg-config', '--variable=confdir', 'fontconfig').stdout().strip()
bundle_app_sh = find_program(meson.project_source_root() / 'tools/osx-bundle.sh')
run_target('osx-bundle',
- command: [bundle_app_sh, meson.project_source_root(), meson.project_build_root(), 'wx-config', fontconfig_conf, '',
+ command: [bundle_app_sh, meson.project_source_root(), meson.project_build_root(), 'wx-config', fontconfig_conf, '@DICT_DIR@',
get_option('build_osx_bundle') ? 'TRUE' : 'FALSE'])
build_dmg_sh = find_program(meson.project_source_root() / 'tools/osx-dmg.sh')
run_target('osx-build-dmg',
diff --git a/tools/osx-bundle.sh b/tools/osx-bundle.sh
index 813151a55..7e856c478 100755
--- a/tools/osx-bundle.sh
+++ b/tools/osx-bundle.sh
@@ -58,8 +58,8 @@ cd ${CURRENT_DIR}
echo
echo "---- Copying dictionaries ----"
-if test -f "${DICT_DIR}"; then
- cp -v "${DICT_DIR}/*" "${PKG_DIR}/Contents/SharedSupport/dictionaries"
+if test -d "${DICT_DIR}"; then
+ cp -v "${DICT_DIR}"/* "${PKG_DIR}/Contents/SharedSupport/dictionaries"
else
mkdir -p "${BUILD_DIR}/dictionaries"
if ! test -f "${BUILD_DIR}/dictionaries/en_US.aff"; then
@@ -103,7 +103,7 @@ mkdir -vp "${PKG_DIR}/Contents/Resources/en.lproj"
echo
echo "---- Fixing libraries ----"
-sudo python3 "${SRC_DIR}/tools/osx-fix-libs.py" "${PKG_DIR}/Contents/MacOS/aegisub" || exit $?
+python3 "${SRC_DIR}/tools/osx-fix-libs.py" "${PKG_DIR}/Contents/MacOS/aegisub" || exit $?
echo
echo "---- Resigning ----"
diff --git a/tools/osx-fix-libs.py b/tools/osx-fix-libs.py
index 7a7930d88..e487ef10c 100644
--- a/tools/osx-fix-libs.py
+++ b/tools/osx-fix-libs.py
@@ -80,7 +80,7 @@ def collectlibs(lib, masterlist, targetdir):
check = l
link_list = []
- while check:
+ while os.path.exists(check):
basename = os.path.basename(check)
target = os.path.join(targetdir, basename)
diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake
index 0b5ea94dcf..1e3559274d 100644
--- a/build/cmake/files.cmake
+++ b/build/cmake/files.cmake
@@ -609,7 +609,6 @@ set(BASE_CMN_HDR
wx/textbuf.h
wx/textfile.h
wx/thread.h
- wx/thrimpl.cpp
wx/time.h
wx/timer.h
wx/tls.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment