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

Running Nyxt on Nix #984

Closed
tmplt opened this issue Oct 4, 2020 · 68 comments
Closed

Running Nyxt on Nix #984

tmplt opened this issue Oct 4, 2020 · 68 comments
Labels

Comments

@tmplt
Copy link

tmplt commented Oct 4, 2020

Describe the bug
copy-url, copy-hint-url, and next-version yield the error in the output below.

Precise recipe to reproduce the issue
Open any buffer, try to run copy-url or copy-hint-url. Alternatively try to run next-version.

Information

  • OS name+version: NixOS 20.03

  • Graphics card and driver:

  • Desktop environment / Window manager name+version: XMonad

  • How you installed Nyxt (Guix pack, package manager, build from source): nix-env -Ai nixos.next

  • Information from command copy-system-information:

    If you can't run copy-system-information, please provide the following:

    • Nyxt version (from =M-x nyxt-version= or =nyxt --version=): N/A
    • Lisp implementation/version (if built from source):
    • Kernel name+version: Linux 5.4.54 #1-NixOS
    • WebKitGTK+ | QtWebEngine version: 1.4.0, according to output below

Output when started from a shell

Next version 1.4.0
Loading configuration from #P"/home/tmplt/.config/next/init.lisp"...
 <INFO> [21:04:20] next remote.lisp (initialize-instance :after remote-interface) -
  D-Bus addresses: (#<Unix socket address: @"/tmp/dbus-MGDDdBOAVW">)
 <INFO> [21:04:20] next remote.lisp (initialize-instance :after remote-interface) -
  Bus connection name: :1.46282
 <INFO> [21:04:20] next port.lisp (run-program port) -
  Current directory: /home/tmplt/
 <INFO> [21:04:20] next port.lisp (run-program port) -
  Platform port path: /nix/store/983caplr60pc0yi9lmnaj639i7jzm0a1-next-gtk-webkit-1.4.0/bin/next-gtk-webkit
 <INFO> [21:04:20] next port.lisp (run-program port) -
  Platform port arguments: NIL
 <INFO> [21:04:20] next port.lisp (run-program port) -
  Platform port log file: /home/tmplt/.local/share/next/next-gtk-webkit.log
 <WARN> [21:04:20] next remote.lisp (current-buffer) -
  No active window, picking last active buffer.
 [...]
WARNING:
   Method handler (NEXT::CORE-OBJECT
                   NEXT::PUSH-INPUT-EVENT) signaled an error: Couldn't execute "": No such file or directory.

@jmercouris
Copy link
Member

Thank you for your report and interest! It seems trivial clipboard is not finding xclip on your system. Can you please try installing the latest Nyxt from source?

@tmplt
Copy link
Author

tmplt commented Oct 4, 2020

I'll need to properly override the Nix derivation which I'm having some problems with. Has someone already done this for HEAD of master? Pinging @nlewo who maintains the package in nixpkgs and might know.

So far I have

      nyxt = next.overrideDerivation (old: {
        name = "next";
        version = "git";
        
        src = fetchFromGitHub {
          owner = "atlas-engineer";
          repo = "next";
          rev = "54b0639e257d0252171d36e8bfe517f986040080"; # HEAD as of writing
          sha256 = "0iba5db8xa2kjizhidmlihg5s82lps6absi1g0gxkv1h135skax3";
          fetchSubmodules = true;
        };

        prePatch = "";
        buildPhase = "make all";
      });

which fails complaining that it can't find alexandria, but its in next.buildInputs.

@jmercouris
Copy link
Member

More likely @walseb can help you, as he has the latest master running on his system.

@walseb
Copy link
Contributor

walseb commented Oct 5, 2020

I'm pretty sure that's because of the new lisp dependencies added since the old nixpgs version. I will send you my nix file that just fetches everything that's needed after work. But it won't build as a pure build script because it relies on quicklisp to download all the lisp dependencies because cl-containers for example isn't up on nixpkgs. Instead if you want to you it you need to clone this repo and run make inside nix-shell. This issue goes into more detail #753

@walseb
Copy link
Contributor

walseb commented Oct 5, 2020

Oh and then you might also run into this problem #925

@walseb
Copy link
Contributor

walseb commented Oct 5, 2020

Oh sorry I didn't read your last paragraph. I think the problem there is that you need to put it in native build inputs or whatever it's called. But even if you solve that problem you still need cl-containers which isn't in nixpkgs.

@walseb
Copy link
Contributor

walseb commented Oct 8, 2020

Sorry I forgot to post until now. This is my shell.nix file. It uses libressl instead of openssl and is a bit messy

{ pkgs ? import <nixpkgs> {} } :
with builtins;
let inherit (pkgs) stdenv; in
with pkgs;
stdenv.mkDerivation {
  name = "next-dev";

  nativeBuildInputs = [
    pkgs.libressl.out
    pkgs.webkitgtk
    pkgs.sbcl
  ];
  # ++ (with pkgs.lispPackages; [
    #   # prove-asdf
    #   # trivial-features
    # ]
  # );

  # gst-plugins-bad
  # gst-plugins-ugly

  buildInputs = [
    pkgs.enchant.out
    pkgs.gsettings-desktop-schemas.out
    pkgs.glib-networking.out
    pkgs.pango.out
    pkgs.cairo.out
    pkgs.gtkd.out
    pkgs.gdk-pixbuf.out
    pkgs.gtk3.out
    pkgs.glib.out
    pkgs.libfixposix.out
    pkgs.webkitgtk
  ] ++
  (with gst_all_1; [
      gst-plugins-base
      gst-plugins-good
      gst-plugins-bad
      gst-plugins-ugly
      gst-libav
  ]);

  propogatedBuildInputs = [
    pkgs.enchant.out
    pkgs.gsettings-desktop-schemas.out
    pkgs.glib-networking.out
    pkgs.pango.out
    pkgs.cairo.out
    pkgs.gtkd.out
    pkgs.gdk-pixbuf.out
    pkgs.gtk3.out
    pkgs.glib.out
    pkgs.libfixposix.out
    pkgs.webkitgtk
  ];

  LD_LIBRARY_PATH = with stdenv.lib; "${makeLibraryPath [ pkgs.gsettings-desktop-schemas.out pkgs.enchant.out pkgs.glib-networking.out pkgs.webkitgtk pkgs.gtk3 pkgs.pango.out pkgs.cairo.out pkgs.gdk-pixbuf.out pkgs.gtkd.out pkgs.glib.out pkgs.libfixposix.out pkgs.libressl.out ]};";

  GIO_MODULE_DIR = "${pkgs.glib-networking.out}/lib/gio/modules/";
  GIO_EXTRA_MODULES = "${pkgs.glib-networking.out}/lib/gio/modules/";
}

@Ambrevar
Copy link
Member

Ambrevar commented Oct 9, 2020 via email

@jmercouris
Copy link
Member

@walseb

Thank you! I've added your shell.nix to the repository. Can you produce a standalone executable using the shell.nix file? If so, how do you do it on NixOS?

@jmercouris
Copy link
Member

In other words, how can we turn your nix shell into a nix package definition?

@walseb
Copy link
Contributor

walseb commented Oct 17, 2020

The only thing stopping us as discussed in #753 is that cl-containers and maybe a few other packages aren't included in the nix repos. Nix builds are (almost) pure, so they don't have access to the internet (hence no quicklisp access), only nixpkgs. The script I put up makes use of quicklisp that's included as a submodule in this package to download cl-containers. As far as I know they don't actually need to add these packages manually, they just need to bump all version numbers and such. @bqv seems to know about this more than I do though.

Oh and I just noticed, you might want to change sbcl to sbcl_2_0_2 in the shell.nix. It's unclear but it might only work with 2_0_2, that's the way it is on my machine anyways (ref #925)

@jmercouris
Copy link
Member

I see, thank you. Hopefully we can get this packaged for Nix!

In the meantime, is there a way to utilize your script to make an executable?

@jmercouris
Copy link
Member

I am very new to NixOS, and I have used the script verbatim as it is in the shell.nix and I am able to run Nyxt, so I don't know if it is necessary to use sbcl_2_0_2.

@walseb
Copy link
Contributor

walseb commented Oct 17, 2020

Great! The way you probably did it (by just using the shell.nix script to get the dependencies then running make all) is the only way I know of to generate an executable using it. To actually package nyxt 2 we would need all lisp dependencies to be in nixpkgs

@bqv
Copy link
Contributor

bqv commented Oct 17, 2020

For the record, I just get around that by breaking the sandbox. I'm also not sure my derivation even works for the newest commit

@jmercouris jmercouris changed the title copy-url, next-version: Couldn't execute "": No such file or directory Running Nyxt on Nix Oct 21, 2020
@jmercouris
Copy link
Member

The following Lisp packages must be added:

  • chanl
  • cl-containers
  • moptilities
  • osicat
  • trivial-package-local-nicknames

The following Lisp packages should be updated if possible:

  • prove-asdf
  • trivial-features
  • alexandria
  • bordeaux-threads
  • cl-css
  • cl-json
  • cl-markup
  • cl-ppcre
  • cl-ppcre-unicode
  • cl-prevalence
  • closer-mop
  • dexador
  • enchant
  • iolib
  • local-time
  • log4cl
  • mk-string-metrics
  • parenscript
  • quri
  • serapeum
  • str
  • plump
  • swank
  • trivia
  • trivial-clipboard
  • trivial-features
  • trivial-types
  • unix-opts
  • usocket

Then, hopefully we can have it packaged for Nix!

@jmercouris
Copy link
Member

@tg-x

@bqv
Copy link
Contributor

bqv commented Oct 24, 2020

LispPackages has been updated on nixpkgs master (will reach unstable-small and unstable in a few days respectively).

In the mean time, here is a poorly written derivation that seems to work reasonably: https://github.com/bqv/nixrc/blob/live/pkgs/applications/networking/browsers/nyxt/default.nix

@jmercouris
Copy link
Member

Packages have been very kindly updated by @7c6f434c

NixOS/nixpkgs#92763

@jmercouris
Copy link
Member

thanks for sharing @bqv, and thank you for following through with your help!

@jmercouris
Copy link
Member

@bqv how would a user utilize your derivation in the meantime? I tried copying the derivation into a file titled 'default.nix' and then executing the following command:
nix-env -i -f default.nix

however, I was met with:

error: cannot auto-call a function that has an argument without a default value ('stdenv')

@bqv
Copy link
Contributor

bqv commented Oct 27, 2020

That particular file, I think you could run with nix-build --expr 'with import <nixpkgs> {}; pkgs.callPackage ./default.nix {} assuming you still had it as default.nix. It may so happen that it might fail on non-nixos, though.

Either way, there is now a bona-fide nyxt package in nixpkgs (pkgs.nyxt as of http://github.com/nixos/nixpkgs/commit/be17edc) so you might as well update and use that

@jmercouris
Copy link
Member

that would mean adding the unstable channel and then installing it? yes?

@jmercouris
Copy link
Member

excuse my ignorance, i am very new to Nix and still trying to wrap my head around many concepts.

@bqv
Copy link
Contributor

bqv commented Oct 27, 2020

that would mean adding the unstable channel and then installing it? yes?

Yes. You might also be able to use the following:

# build nyxt and link the result to ./result (it's only in unstable-small so far)
nix-build channel:nixos-unstable-small -A nyxt

# install it, if you want
nix-env -i ./result

# or just run it
./result/bin/nyxt

@jmercouris
Copy link
Member

I see, thank you.

@bqv
Copy link
Contributor

bqv commented Oct 30, 2020

@tmplt unless you're still experiencing this error, this can be closed, as it should be solved in the nixpkgs version, which has now reached nixos-unstable

@tmplt
Copy link
Author

tmplt commented Oct 31, 2020 via email

@Ambrevar
Copy link
Member

Ambrevar commented Nov 2, 2020 via email

@Ambrevar
Copy link
Member

Ambrevar commented Nov 14, 2020 via email

@Ambrevar
Copy link
Member

Ambrevar commented Nov 14, 2020 via email

@pmiddend
Copy link

I'm not sure how to build and use nyxt on Nix. nix-build fails with:

builder for '/nix/store/nlmc4s1mchgmfl3gvsvkwnvqk30wzyns-lisp-nyxt-git.drv' failed with exit code 1; last 10 log lines:  (asdf:load-system :nyxt)
  (asdf:operate (quote asdf::compile-bundle-op) :nyxt)
  (ignore-errors (asdf:operate (quote asdf::deploy-asd-op) :nyxt))
  (asdf:compile-sy... {1004BDCBCF}>) (:EVAL . "(quit)") (:QUIT)))
  55: (SB-IMPL::TOPLEVEL-INIT)
  56: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP))
  57: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-IMPL::START-LISP))
  58: (SB-IMPL::START-LISP)
  
  unhandled condition in --disable-debugger mode, quitting

when having flake enable. Without it, it fails with a different error.

@loafofpiecrust
Copy link

I have the same issue with nix develop --impure (flakes) and nix-build -I nixpkgs=channel:nixpkgs-unstable!
The initial error appears to be this:

Unhandled ASDF/FIND-COMPONENT:MISSING-DEPENDENCY in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                                              {10008B80D3}>:
  Component ASDF/USER::CL-CUSTOM-HASH-TABLE not found, required by
  #<SYSTEM "nyxt/history-tree">

But at the beginning of the build I also get this:

mkdir: cannot create directory '/homeless-shelter': Permission denied

I'd love to start hacking on Nyxt but I don't know much about CL builds yet so not sure I can contribute a fix.

@jmercouris
Copy link
Member

jmercouris commented Feb 20, 2021

What I have done is the following:

I add the following to default.nix within Nyxt:
  + nix-lisp.cl-custom-hash-table

Then I:
+ sudo nixos-rebuild switch -I nixpkgs=$PWD
+ nix-build -I nixpkgs=channel:nixpkgs-unstable
+ nix-env -i -f default.nix -I nixpkgs=channel:nixpkgs-unstable

hopefully that helps!

@pmiddend
Copy link

Thanks @jmercouris. I tried adding cl-custom-hash-table. I indeed get farther, up until:

; caught ERROR:
;   READ error during COMPILE-FILE:
;   
;     Symbol "WEBKIT-DOWNLOAD-CANCEL" not found in the CL-WEBKIT2 package.
;   
;       Line: 866, Column: 53, File-Position: 38760
;   
;       Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /nix/store/kj7nnzhhcqxmnnwym2kww3lbwskvgsc7-lisp-nyxt-git/lib/common-lisp/nyxt/source/renderer-gtk.lisp" {1008647663}>

; compilation aborted after 0:00:00.304

Maybe the cl-webkit package in nixpkgs is a different (probably lower) version than you expect?

@jmercouris
Copy link
Member

Ah that's true, it is , I also commented out the code that relied on that!

@pmiddend
Copy link

Ah, okay. Can you be a bit more specific?

In a more general sense, isn't basing the .nix expressions in this repository off of the one in nixpkgs a bit brittle? Copying it from nixpkgs and maintaining it separately seems a bit more consolidated. But I'm certainly no Nix expert.

@jmercouris
Copy link
Member

I commented out line 865 in renderer-gtk.lisp, which should look like this:

(setf (cancel-function download)
          #'(lambda () (webkit:webkit-download-cancel webkit-download)))

@jmercouris
Copy link
Member

You could just comment out the whole ffi-buffer-download method in renderer-gtk.lisp, and it should then work.

@pmiddend
Copy link

Thanks @jmercouris, it works now!

Of course, this issue should stay open until it's fixed "for real".

@jmercouris
Copy link
Member

No problem, I am glad to hear it :-)

@tg-x
Copy link

tg-x commented Mar 8, 2021

  ...
  unhandled condition in --disable-debugger mode, quitting

i get the same error both with & without flakes, any ideas?

@Ambrevar Ambrevar added the build label Mar 24, 2021
@7c6f434c
Copy link

Have the updates on the Nixpkgs side help anything?

@jmercouris
Copy link
Member

Indeed they have :-), thank you very much for your help. What they have not completely solved is xclip. I had to install it nix-env -i xclip for coyping the URL to function. It is a run-time dependency of trivial-clipboard (under X, of course).

@Ambrevar
Copy link
Member

Ambrevar commented Apr 21, 2021 via email

@7c6f434c
Copy link

Hmm. Good question whether to make both mandatory dependencies of trivial-clipboard (by patching in the full paths)

@Ambrevar
Copy link
Member

Ambrevar commented Apr 23, 2021 via email

@DieracDelta
Copy link
Contributor

Hey folks. The nixpkgs version of Nix is still at 2.0.0. I recently figured out how to get it working via overlay. Basically copying the changes from https://github.com/NixOS/nixpkgs/pull/131665/files. In case others are interested:

        (final: prev: {
          lispPackages = prev.lispPackages // {
            cl-webkit2 = prev.lispPackages.cl-webkit2.overrideAttrs (oldAttrs:
            {
              src = prev.fetchFromGitHub {
                owner = "joachifm";
                repo = "cl-webkit";
                rev = "90b1469713265096768fd865e64a0a70292c733d";
                sha256 = "sha256:0lxws342nh553xlk4h5lb78q4ibiwbm2hljd7f55w3csk6z7bi06";
              };
            });
            nyxt = prev.lispPackages.nyxt.overrideAttrs (oldAttrs:
          {
            version = "2.1.1";
            src = prev.fetchFromGitHub {
              owner = "atlas-engineer";
              repo = "nyxt";
              rev = "93a2af10f0b305740db0a3232ecb690cd43791f9";
              sha256 = "sha256-GdTOFu5yIIL9776kfbo+KS1gHH1xNCfZSWF5yHUB9U8=";
            };
          });
        };
        })

@DieracDelta
Copy link
Contributor

Follow up question: why was the flake.nix removed? NixOS flakes are quickly becoming a standard feature (https://discourse.nixos.org/t/nix-release-schedule-and-roadmap/14204). Other projects (for example neovim) have a flake.nix. I think it would be keep to stay up to date with a flake (and make it easier for new NixOS users).

@jmercouris
Copy link
Member

Flakes are not yet a standard feature, when they are, I can re-add them.

@jmercouris
Copy link
Member

As per updating Nyxt: NixOS/nixpkgs#131665

ambroisie added a commit to ngi-nix/nyxt that referenced this issue Aug 17, 2021
Thanks to @DieracDelta, having done the work previously on [1].

[1]: atlas-engineer/nyxt#984 (comment)
@tg-x
Copy link

tg-x commented Sep 30, 2021

Flakes are not yet a standard feature, when they are, I can re-add them.

i'd like to see the above flake added to the project.
many projects are already using it, including me in all my projects, and it's stable enough to rely on.
it would make it much easier for nix users to build the latest revision and contribute to the project.

@jmercouris
Copy link
Member

Flakes are not yet a standard feature, when they are, I can re-add them.

i'd like to see the above flake added to the project. many projects are already using it, including me in all my projects, and it's stable enough to rely on. it would make it much easier for nix users to build the latest revision and contribute to the project.

Can you please show how a user would build the latest revision using a flake? What commands would they have to type, what would they have to do?

@tg-x
Copy link

tg-x commented Oct 1, 2021

  1. use nix build to build the project then run the binary from the result/ dir (there's also nix run for the latter)
  2. use nix develop to get a development shell with all dependencies available in the enviroment

see also https://nixos.wiki/wiki/Flakes

@aadcg
Copy link
Member

aadcg commented May 31, 2023

Stale.

The latest Nyxt should be soon available on Nix. If you find issues with Nyxt on Nix, please contact the Nix maintainers first. The Nix maintainers can request our help so that we figure it out issues together. Thanks.

@aadcg aadcg closed this as completed May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests