nix-config/patches/nyxt-darwin-build.patch

287 lines
11 KiB
Diff
Raw Normal View History

From 922bd3b630b6e232c1ccab17e70bd14ce84f172d Mon Sep 17 00:00:00 2001
From: midchildan <git@midchildan.org>
Date: Wed, 2 Jun 2021 02:30:44 +0900
Subject: [PATCH 1/2] nyxt: fix darwin build
Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com>
---
.../networking/browsers/nyxt/default.nix | 104 +++++++++++++-----
.../lisp-modules/lisp-packages.nix | 44 ++++++--
2 files changed, 107 insertions(+), 41 deletions(-)
diff --git a/pkgs/applications/networking/browsers/nyxt/default.nix b/pkgs/applications/networking/browsers/nyxt/default.nix
index 59bb2adbf5182..5af706a73d56c 100644
--- a/pkgs/applications/networking/browsers/nyxt/default.nix
+++ b/pkgs/applications/networking/browsers/nyxt/default.nix
@@ -1,9 +1,19 @@
-{ stdenv, lib, lispPackages
-, makeWrapper, wrapGAppsHook, gst_all_1
-, glib, gdk-pixbuf, cairo
-, mime-types, pango, gtk3
-, glib-networking, gsettings-desktop-schemas
-, xclip, notify-osd, enchant
+{ lib
+, stdenv
+, cairo
+, enchant
+, gdk-pixbuf
+, glib
+, glib-networking
+, gobject-introspection
+, gsettings-desktop-schemas
+, gtk3
+, gst_all_1
+, lispPackages
+, mime-types
+, pango
+, wrapGAppsHook
+, xclip
}:
stdenv.mkDerivation rec {
@@ -12,39 +22,75 @@ stdenv.mkDerivation rec {
src = lispPackages.nyxt;
- nativeBuildInputs = [ makeWrapper wrapGAppsHook ];
- gstBuildInputs = with gst_all_1; [
- gstreamer gst-libav
+ nativeBuildInputs = [ wrapGAppsHook ];
+ buildInputs = [
+ cairo
+ enchant
+ gdk-pixbuf
+ glib
+ glib-networking
+ gobject-introspection
+ gsettings-desktop-schemas
+ gtk3
+ mime-types
+ pango
+ ] ++ (with gst_all_1; [
+ gstreamer
+ gst-libav
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
- ];
- buildInputs = [
- glib gdk-pixbuf cairo
- mime-types pango gtk3
- glib-networking gsettings-desktop-schemas
- xclip notify-osd enchant
- ] ++ gstBuildInputs;
+ ]);
- GST_PLUGIN_SYSTEM_PATH_1_0 = lib.concatMapStringsSep ":" (p: "${p}/lib/gstreamer-1.0") gstBuildInputs;
+ binPath = lib.optionals (!stdenv.isDarwin) [ xclip ];
+ doInstallCheck = !stdenv.isDarwin;
+ dontBuild = true;
dontWrapGApps = true;
+
+ # stripping breaks the Linux build, possibly because the resulting binary is
+ # already stripped once in lispPackages.nyxt
+ dontStrip = true;
+
installPhase = ''
- mkdir -p $out/share/applications/
- sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
- for i in 16 32 128 256 512; do
- mkdir -p "$out/share/icons/hicolor/''${i}x''${i}/apps/"
- cp -f $src/lib/common-lisp/nyxt/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
- done
-
- mkdir -p $out/bin && makeWrapper $src/bin/nyxt $out/bin/nyxt \
- --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "${GST_PLUGIN_SYSTEM_PATH_1_0}" \
- --argv0 nyxt "''${gappsWrapperArgs[@]}"
- '';
+ runHook preInstall
+ '' + (if stdenv.isDarwin then ''
+ mkdir -p $out/bin $out/Applications/Nyxt.app/Contents
+ pushd $out/Applications/Nyxt.app/Contents
+ install -Dm644 $src/lib/common-lisp/nyxt/assets/Info.plist Info.plist
+ install -Dm644 $src/lib/common-lisp/nyxt/assets/nyxt.icns Resources/nyxt.icns
+ install -Dm755 $src/bin/nyxt MacOS/nyxt
+ popd
+
+ gappsWrapperArgsHook # FIXME: currently runs at preFixup
+ wrapGApp $out/Applications/Nyxt.app/Contents/MacOS/nyxt \
+ --prefix PATH : "${lib.makeBinPath binPath}" \
+ --argv0 nyxt
+
+ ln -s $out/Applications/Nyxt.app/Contents/MacOS/nyxt $out/bin/nyxt
+ '' else ''
+ mkdir -p $out/share/applications/
+ sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
+ for i in 16 32 128 256 512; do
+ mkdir -p "$out/share/icons/hicolor/''${i}x''${i}/apps/"
+ cp -f $src/lib/common-lisp/nyxt/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
+ done
+
+ install -Dm755 $src/bin/nyxt $out/bin/nyxt
+
+ gappsWrapperArgsHook # FIXME: currently runs at preFixup
+ wrapGApp $out/bin/nyxt \
+ --prefix PATH : "${lib.makeBinPath binPath}" \
+ --argv0 nyxt
+ '') + ''
+ runHook postInstall
+ '';
- checkPhase = ''
+ installCheckPhase = ''
+ runHook preCheck
$out/bin/nyxt -h
+ runHook postCheck
'';
meta = with lib; {
diff --git a/pkgs/development/lisp-modules/lisp-packages.nix b/pkgs/development/lisp-modules/lisp-packages.nix
index e4f623686a9af..74ae5a05b575d 100644
--- a/pkgs/development/lisp-modules/lisp-packages.nix
+++ b/pkgs/development/lisp-modules/lisp-packages.nix
@@ -129,22 +129,42 @@ let lispPackages = rec {
description = "Browser";
overrides = x: {
+ patches = [
+ # Fixes a startup crash on Darwin
+ # https://github.com/atlas-engineer/nyxt/pull/1476
+ (pkgs.fetchpatch {
+ url = "https://github.com/midchildan/nyxt/commit/6184884b48b7cacdc51d104cb2299c26437a73d8.diff";
+ sha256 = "sha256-A8Hwfjn/B5fv8OTKM5i9YrNFAMbPAg9xRH7gwoMMlQs=";
+ })
+
+ # Fix list-buffers
+ (pkgs.fetchpatch {
+ url = "https://github.com/atlas-engineer/nyxt/commit/4e2efb5a456d8d647f3eeaeb52cb21f96c92471c.diff";
+ sha256 = "sha256-xt+jXZlTktznAoEWsaO5uQywo+bR9PecgTKOjY7UNvY=";
+ })
+
+ # Fix non-functional "Update" button in the buffer list
+ # https://github.com/atlas-engineer/nyxt/pull/1484
+ (pkgs.fetchpatch {
+ url = "https://github.com/midchildan/nyxt/commit/7589181d6e367442bad8011f0ef5b42fc1cfd3c5.diff";
+ sha256 = "sha256-4uXm7yxkhcArk39JBealGr1N4r/8AM5v/1VYHw1y4hw=";
+ })
+ ];
+
postInstall = ''
echo "Building nyxt binary"
- (
- source "$out/lib/common-lisp-settings"/*-shell-config.sh
- cd "$out/lib/common-lisp"/*/
- makeFlags="''${makeFlags:-}"
- make LISP=common-lisp.sh NYXT_INTERNAL_QUICKLISP=false PREFIX="$out" $makeFlags all
- make LISP=common-lisp.sh NYXT_INTERNAL_QUICKLISP=false PREFIX="$out" $makeFlags install
- cp nyxt "$out/bin/nyxt"
- )
+
+ # clear unnecessary environment variables to avoid hitting the limit
+ env -i \
+ NIX_LISP="$NIX_LISP" \
NIX_LISP_PRELAUNCH_HOOK='
- nix_lisp_build_system nyxt/gtk-application \
- "(asdf/system:component-entry-point (asdf:find-system :nyxt/gtk-application))" \
- "" "(format *error-output* \"Alien objects:~%~s~%\" sb-alien::*shared-objects*)"
+ nix_lisp_build_system nyxt/gi-gtk-application \
+ "(asdf/system:component-entry-point (asdf:find-system :nyxt/gi-gtk-application))" \
+ "" \
+ "(format *error-output* \"Alien objects:~%~s~%\" sb-alien::*shared-objects*)"
' "$out/bin/nyxt-lisp-launcher.sh"
- cp "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
+
+ mv "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
'';
};
From c6598c61e74135b3b3848da46af62f0ee59ce9aa Mon Sep 17 00:00:00 2001
From: midchildan <git@midchildan.org>
Date: Tue, 8 Jun 2021 03:30:00 +0900
Subject: [PATCH 2/2] lispPackages.nyxt-unwrapped: rename from
lispPackages.nyxt
---
.../networking/browsers/nyxt/default.nix | 12 ++++++------
pkgs/development/lisp-modules/lisp-packages.nix | 11 +++++++----
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/pkgs/applications/networking/browsers/nyxt/default.nix b/pkgs/applications/networking/browsers/nyxt/default.nix
index 5af706a73d56c..6b00e54794728 100644
--- a/pkgs/applications/networking/browsers/nyxt/default.nix
+++ b/pkgs/applications/networking/browsers/nyxt/default.nix
@@ -18,9 +18,9 @@
stdenv.mkDerivation rec {
pname = "nyxt";
- inherit (lispPackages.nyxt.meta) version;
+ inherit (lispPackages.nyxt-unwrapped.meta) version;
- src = lispPackages.nyxt;
+ src = lispPackages.nyxt-unwrapped;
nativeBuildInputs = [ wrapGAppsHook ];
buildInputs = [
@@ -58,8 +58,8 @@ stdenv.mkDerivation rec {
'' + (if stdenv.isDarwin then ''
mkdir -p $out/bin $out/Applications/Nyxt.app/Contents
pushd $out/Applications/Nyxt.app/Contents
- install -Dm644 $src/lib/common-lisp/nyxt/assets/Info.plist Info.plist
- install -Dm644 $src/lib/common-lisp/nyxt/assets/nyxt.icns Resources/nyxt.icns
+ install -Dm644 $src/lib/common-lisp/nyxt-unwrapped/assets/Info.plist Info.plist
+ install -Dm644 $src/lib/common-lisp/nyxt-unwrapped/assets/nyxt.icns Resources/nyxt.icns
install -Dm755 $src/bin/nyxt MacOS/nyxt
popd
@@ -71,10 +71,10 @@ stdenv.mkDerivation rec {
ln -s $out/Applications/Nyxt.app/Contents/MacOS/nyxt $out/bin/nyxt
'' else ''
mkdir -p $out/share/applications/
- sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
+ sed "s/VERSION/$version/" $src/lib/common-lisp/nyxt-unwrapped/assets/nyxt.desktop > $out/share/applications/nyxt.desktop
for i in 16 32 128 256 512; do
mkdir -p "$out/share/icons/hicolor/''${i}x''${i}/apps/"
- cp -f $src/lib/common-lisp/nyxt/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
+ cp -f $src/lib/common-lisp/nyxt-unwrapped/assets/nyxt_''${i}x''${i}.png "$out/share/icons/hicolor/''${i}x''${i}/apps/nyxt.png"
done
install -Dm755 $src/bin/nyxt $out/bin/nyxt
diff --git a/pkgs/development/lisp-modules/lisp-packages.nix b/pkgs/development/lisp-modules/lisp-packages.nix
index 74ae5a05b575d..10eb880fe663a 100644
--- a/pkgs/development/lisp-modules/lisp-packages.nix
+++ b/pkgs/development/lisp-modules/lisp-packages.nix
@@ -122,8 +122,8 @@ let lispPackages = rec {
asdFilesToKeep = [ "cluffer.asd" "cluffer-base.asd" "cluffer-simple-buffer.asd" "cluffer-simple-line.asd" "cluffer-standard-buffer.asd" "cluffer-standard-line.asd" ];
};
- nyxt = pkgs.lispPackages.buildLispPackage rec {
- baseName = "nyxt";
+ nyxt-unwrapped = pkgs.lispPackages.buildLispPackage rec {
+ baseName = "nyxt-unwrapped";
version = "2.0.0";
description = "Browser";
@@ -162,9 +162,9 @@ let lispPackages = rec {
"(asdf/system:component-entry-point (asdf:find-system :nyxt/gi-gtk-application))" \
"" \
"(format *error-output* \"Alien objects:~%~s~%\" sb-alien::*shared-objects*)"
- ' "$out/bin/nyxt-lisp-launcher.sh"
+ ' "$out/bin/${baseName}-lisp-launcher.sh"
- mv "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
+ mv "$out/lib/common-lisp/${baseName}/nyxt" "$out/bin/"
'';
};
@@ -225,5 +225,8 @@ let lispPackages = rec {
pkgs.sbcl
];
};
+
+ # added 2021-06-14
+ nyxt = throw "lispPackages.nyxt was renamed to lispPackages.nyxt-unwrapped";
};
in lispPackages