Navigation Menu

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

gnomeExtensions.drop-down-terminal: init at v24 #69834

Closed
wants to merge 6 commits into from

Conversation

ericdallo
Copy link
Member

Motivation for this change

Add the drop down terminal GNOME shell extension.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: GNOME GNOME desktop environment and its underlying platform label Sep 28, 2019
@hedning
Copy link
Contributor

hedning commented Sep 28, 2019

This one require a few dependencies at runtime which needs fixing:

ericdallo and others added 2 commits September 29, 2019 00:44
Co-Authored-By: worldofpeace <worldofpeace@protonmail.ch>
Co-Authored-By: worldofpeace <worldofpeace@protonmail.ch>
@ericdallo
Copy link
Member Author

ericdallo commented Sep 29, 2019

@hedning
I dont know how I can perform this changes. For the first one, Do I need to create a patch for my pkg and in this other pkg, somehow download and install this typelib from vte?

And for the second, I should change in the instalPhase to use absolutePath right? I tried to use inside the installPhase Posix.system("@coreutils@/bin/mkdir -p $out/share/gnome-shell/extensions"); but is not working :/

@hedning
Copy link
Contributor

hedning commented Sep 29, 2019

Ah, right, I only meant that the fixes needed here are the same kind of fixes that I referenced.

So the patch will look something like this:

modified   drop-down-terminal@gs-extensions.zzrough.org/extension.js
@@ -15,6 +15,8 @@
 
 // Author: Stéphane Démurget <stephane.demurget@free.fr>
 
+imports.gi.GIRepository.Repository.prepend_search_path('@vte@/lib/lib/girepository-1.0')
+
 const Lang = imports.lang;
 const Gettext = imports.gettext.domain("drop-down-terminal");
 const Mainloop = imports.mainloop;
@@ -653,7 +655,7 @@ const DropDownTerminalExtension = new Lang.Class({
         this._killingChild = false;
 
         // finds the forking arguments
-        let args = ["gjs", GLib.build_filenamev([Me.path, "terminal.js"]), Me.path];
+        let args = ["@gjs@/bin/gjs", GLib.build_filenamev([Me.path, "terminal.js"]), Me.path];
 
         // forks the process
         debug("forking '" + args.join(" ") + "'");

And then @vte@ and @gjs@ just needs to be replaced with the correct paths when building. We have a convenient utility for this. This will find occurrences of the names to the left surrounded with @ and replace them with the expression to the right. So in nix eg. the package vte simply expands to its nix store path when used as a string (This can be seen in action using nix eval nixpkgs.vte --raw):

patches = [
  (substituteAll {
    src = ./fix_paths.patch;
    vte = vte;
    gjs = gnome3.gjs;
  }

Does that make sense?

@ericdallo
Copy link
Member Author

ericdallo commented Sep 29, 2019

@hedning
Yep, makes total sense, I'm new to this nix world, but I think I got it how this works now.
I created the patch with the diff, let me know if something is missing.

One question, how do you test this and know that some libs needs absolutePath? I'm just running nix-build -A 'gnomeExtensions.drop-down-terminal' to check if everything its alright

@hedning
Copy link
Contributor

hedning commented Sep 29, 2019

Right, you basically need to run things and see if they work. For regular programs that's usually as simple as result/bin/program.

In the case of gnome-shell extensions we need to run gnome-shell and activate the extension. Doing this in your current gnome-shell can be a bit annoying. To solve that there's two options:

  • run a virtual machine
  • run a nested gnome-shell session

Building a virtual machine can be very useful in general. Put something like into vm.nix in your nixpkgs repo:

{ pkgs, config, ... }:
{
  environment.systemPackages = with pkgs; [
    gnomeExtensions.drop-down-terminal
  ];

  services.openssh.enable = true;
  boot.cleanTmpDir = true;

  services.xserver = {
    enable = true;

    desktopManager = {
      gnome3.enable = true;
      gnome3.debug = true;
    };

    displayManager = {
      gdm.enable = true;
      gdm.debug = true;
    };
  };

  users.users.foo = {
    isNormalUser = true;
    uid = 1000;
    password = "foobar";
    extraGroups = [ "wheel" "networkmanager" ];
    openssh.authorizedKeys.keys = [
      # put your machines public key here to get ssh access
    ];
  };

  system.stateVersion = "16.09";
}

And then build and run the VM like this for instance:

nixos-rebuild build-vm -I nixpkgs=./. -I nixos-config=./vm.nix
QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm -m 2500

Then you can log in and activate the extension with gnome-tweaks.

Now that takes a while. I use this script through emacs (session.sh) to easily launch nested gnome-shells to test and develop extensions. For that something like this should work:

nix build -f. gnomeExtensions.drop-down-terminal
session.sh wayland result/share/gnome-shell/extensions/drop-down-terminal@gs-extensions.zzrough.org/ drop-down-terminal@gs-extensions.zzrough.org

@ericdallo
Copy link
Member Author

Uow, its a great way to test, I'll try to setup this and test this whole thing, thank you!

@ericdallo
Copy link
Member Author

I fixed the vte path, but this time, ther is no error message, so i cannot figure out what is wrong...

When I activate the extension, only this message shows:
image

And on Looking-glass, there's no error message:
image

@hedning
Copy link
Contributor

hedning commented Sep 29, 2019

Right, looks like terminal.js also needs the imports.gi.GIRepository.Repository.prepend_search_path('@vte@/lib/girepository-1.0') preamble, as it's run in a separate process.

@ericdallo
Copy link
Member Author

Finally worked!
Thank you for the incredible help and teach @hedning :)

@worldofpeace
Copy link
Contributor

@ericdallo It appears you're trying to merge this into release-19.03 and all contributions should go to master first. You probably want this in the current stable release, so we can backport it after it's merged to master.

@ericdallo
Copy link
Member Author

hum, makes sense @worldofpeace , so i need to open the PR to the master, right?

@worldofpeace
Copy link
Contributor

@ericdallo Likely, it's the easiest route. It also appears you're working directly on the release-19.03 branch and not a feature one.

Best to do

git checkout upstream/master
git checkout -b some-branch-name

@ericdallo
Copy link
Member Author

Got it, I'll create a branch from updated master, open a new PR with theese changes and link it here. Thank you @worldofpeace

vte = vte;
gjs = gnome3.gjs;
})
(substituteAll {
src = ./fix_vte_on_terminal.patch;
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to just put everything into the same file tbh.

@hedning
Copy link
Contributor

hedning commented Sep 30, 2019

Right and squash everything into one commit :)

@ericdallo
Copy link
Member Author

New PR with commits squashed #70042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants