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

add nix flake #332

Closed
wants to merge 1 commit into from
Closed

add nix flake #332

wants to merge 1 commit into from

Conversation

rcambrj
Copy link

@rcambrj rcambrj commented Jan 3, 2025

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea. I'm using this change anyway, feel free to discuss in this pull request!

  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rspec and bundle exec rubocop. no ruby changes necessary so these tasks should still pass

  • Update code documentation if necessary. should I add a section to the readme for nixos?

related to: #323

In the above issue, @TroyMitchell911 reports:

/var/lib/gems/3.0.0/gems/fusuma-plugin-appmatcher-0.7.1/lib/fusuma/plugin/appmatcher/gnome.rb:111:in `gnome_shell_eval': unhandled exception
	from /var/lib/gems/3.0.0/gems/fusuma-plugin-appmatcher-0.7.1/lib/fusuma/plugin/appmatcher/gnome.rb:75:in `active_application'

This is the exact error that I was getting.

The fusuma package is already available in nixpkgs and I'm using it along with the home-manager service and the new gnome extension for which I made a pull request just moments ago.

The nixpkgs fusuma package is outdated (3.5.0 vs 3.7.0), but I updated this package to the latest version in a nixpkgs fork and it still suffers from that same unhandled exception. I'm not yet sure what it is that I've fixed by recreating the derivation directly in this repository, but it works now.

As with the appmatcher gnome extension, you can see an example of how I've implemented this:

https://github.com/rcambrj/dotfiles/blob/b3108d9ae608e2e20eacb318c541b03aa470bd40/flake.nix#L43
https://github.com/rcambrj/dotfiles/blob/b3108d9ae608e2e20eacb318c541b03aa470bd40/hosts/mango/graphical/touchpad.nix
https://github.com/rcambrj/dotfiles/blob/b3108d9ae608e2e20eacb318c541b03aa470bd40/modules/home/rcambrj-graphical/touchpad.nix

If you're against putting nix-specific stuff into this repository, that's understandable, I figured that I would at least share my findings. It may be better to determine what's wrong with the nixpkgs derivation and fix that instead, but at the same time, there's nothing wrong with providing flake.nix in the source repository (its even encouraged where frequent updates are required).

New requirements:

  • Gemfile.lock, as is best practice to commit to the repository and as required by the nix derivation. Generate by running bundle lock
  • gemset.nix, as required by the nix derivation, generate by running bundix

@iberianpig
Copy link
Owner

Firstly, I want to express my gratitude for opening the pull request and for your contributions.

related to: #323
In the above issue, @TroyMitchell911 reports:

/var/lib/gems/3.0.0/gems/fusuma-plugin-appmatcher-0.7.1/lib/fusuma/plugin/appmatcher/gnome.rb:111:in `gnome_shell_eval': unhandled exception
	from /var/lib/gems/3.0.0/gems/fusuma-plugin-appmatcher-0.7.1/lib/fusuma/plugin/appmatcher/gnome.rb:75:in `active_application'

This fusuma-plugin-appmatcher's error is due to appmatcher gnome-extension not being installed.

  • This is a problem that only works with Gnome versions below 41, so I believe that removing old lib/fusuma/plugin/appmatcher/gnome.rb or performing a version check would be a good solution.
  • It would be beneficial to display an error message prompting users, not just those using nix, to install the GnomeExtension.

As I am not a nix user, I currently have no intentions to include nix-specific configurations in this or other repositories. It would be preferable if handling through an external repository such as the nix home-manager could be considered.

As a side note:

  • We do not currently offer configurations for package managers like apt, yum, or brew.
  • The Gemfile within our repository is primarily geared towards developers and includes components not required at runtime, such as ActiveSupport; hence, this approach may not be suitable for all users.

@iberianpig
Copy link
Owner

Thank you once again for your understanding and for your valuable contributions.
If you have any further suggestions or questions, please feel free to reach out.

@iberianpig iberianpig closed this Jan 6, 2025
@rcambrj
Copy link
Author

rcambrj commented Jan 6, 2025

@iberianpig I respect the desire to keep package manager code outside of this repository.

However, with regards to:

This fusuma-plugin-appmatcher's error is due to appmatcher gnome-extension not being installed

That is incorrect, as I already had the appmatcher extension installed and enabled. This unhandled exception was occurring despite the gnome extension being installed. I believe that there is some other dependency which is missing when using the nixpkgs version of fusuma, which I somehow inadvertently fixed in creating a new nix derivation.

I'm not very fluent in Ruby, is there any more information surrounding this unhandled exception which might be useful in identifying the underlying problem? Could the logging of this error be improved in order to determine the cause?

In the meantime, for any nix users looking to fix this problem, use inputs.fusuma.url = "github:rcambrj/fusuma";

@iberianpig
Copy link
Owner

iberianpig commented Jan 6, 2025

Let me provide some background and explain using Ruby code.

The error seems to be similar to what's discussed in Issue #3. The root cause appears to be the limitation imposed by Gnome 41 and later versions on the Eval of JavaScript through D-Bus.

However, there might be a possibility that the Gnome extension is incorrectly detected as not installed by the following code:

see: https://github.com/iberianpig/fusuma-plugin-application_matcher/blob/main/lib/fusuma/plugin/appmatcher.rb?plain=1#L25

      # @return [Class]
      def backend_klass
        case xdg_session_type
        when /x11/
          return X11
        when /wayland/
          case xdg_current_desktop
          when /GNOME/
            return GnomeExtension if GnomeExtensions::Installer.new.installed?

            return Gnome
          end
        end

        UnsupportedBackend
      end

The installation check is done in a straightforward manner by checking if a file exists at a specific path, as shown in the following code. It is possible that, for some reason, the file was not present at that location.

# fusuma-plugin-appmatcher/lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb
EXTENSION = "./[email protected]"

def installed?
  File.exist?(install_path)
end

def install_path(username = login_username)
  File.expand_path("#{Dir.home(username)}/.local/share/gnome-shell/extensions/#{EXTENSION}")
end

Specifically, it checks if a file exists at the following path, and if it does not find a file there, it determines that the extension is not installed:

~/.local/share/gnome-shell/extensions/[email protected]

I hope this information helps in resolving the issue. If you have any further insights or ideas for improvement, I would appreciate your input.

@rcambrj
Copy link
Author

rcambrj commented Jan 6, 2025

Thanks for the explanation, I understand the problem better now: the code in gnome.rb would only execute (and thus error) if the extension was not detected, the extension-related code being in gnome_extension.rb.

This does indeed imply that the difference between nixpkgs#fusuma and rcambrj/fusuma#fusuma is that the latter can somehow detect that the extension is installed. However, even when using the working version, nixos does not put the gnome extensions in this directory (it performs some other magic):

❯ ls ~/.local/share/gnome-shell/extensions
ls: cannot access '/home/rcambrj/.local/share/gnome-shell/extensions': No such file or directory

So I'm still not entirely sure what's making it work right now... I'll do some further investigation into this.

In the meantime, might I suggest a more robust way of determining whether the extension is installed by using gsettings or dconf to query "org/gnome/shell".enabled-extensions?

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

Successfully merging this pull request may close these issues.

2 participants