Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nyxt: fix darwin build #126082

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 77 additions & 31 deletions pkgs/applications/networking/browsers/nyxt/default.nix
Original file line number Diff line number Diff line change
@@ -1,50 +1,96 @@
{ 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 {
pname = "nyxt";
inherit (lispPackages.nyxt.meta) version;
inherit (lispPackages.nyxt-unwrapped.meta) version;

src = lispPackages.nyxt;
src = lispPackages.nyxt-unwrapped;

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xclip in buildInputs doesn't have any effect because it's a CLI tool, not a library. I've added xclip to the wrapper instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notify-osd is removed since it's no longer needed. Details in #125113 (comment).

] ++ gstBuildInputs;
]);

GST_PLUGIN_SYSTEM_PATH_1_0 = lib.concatMapStringsSep ":" (p: "${p}/lib/gstreamer-1.0") gstBuildInputs;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting GST_PLUGIN_SYSTEM_PATH_1_0 is handled by wrapGApps. It suffices to put these in buildInputs.

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 \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't work because gappsWrapperArgs is computed at preFixup, which happens after installPhase.

--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-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

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-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-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

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; {
Expand Down
53 changes: 38 additions & 15 deletions pkgs/development/lisp-modules/lisp-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,49 @@ 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";

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"
)
Comment on lines -134 to -141
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was redundant because it creates a broken build artifact $out/bin/nyxt which promptly gets rebuilt by the subsequent commands.


# clear unnecessary environment variables to avoid hitting the limit
env -i \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary to clear unnecessary environment variables because otherwise it hits the length limit imposed by the OS. This is similar to what is done in lisp-modules/define-package.nix:

env -i \
NIX_LISP="$NIX_LISP" \
NIX_LISP_PRELAUNCH_HOOK='nix_lisp_run_single_form "(progn
${lib.concatMapStrings (system: ''
(asdf:compile-system :${system})
(asdf:load-system :${system})
(asdf:operate (quote asdf::compile-bundle-op) :${system})
(ignore-errors (asdf:operate (quote asdf::deploy-asd-op) :${system}))
'') buildSystems}
)"' \
"$out/bin/${args.baseName}-lisp-launcher.sh"

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*)"
' "$out/bin/nyxt-lisp-launcher.sh"
cp "$out/lib/common-lisp/nyxt/nyxt" "$out/bin/"
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/${baseName}-lisp-launcher.sh"

mv "$out/lib/common-lisp/${baseName}/nyxt" "$out/bin/"
'';
};

Expand Down Expand Up @@ -205,5 +225,8 @@ let lispPackages = rec {
pkgs.sbcl
];
};

# added 2021-06-14
nyxt = throw "lispPackages.nyxt was renamed to lispPackages.nyxt-unwrapped";
};
in lispPackages