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

onedriver: doesn't work on KDE plasma - TLS/SSL support not available; install glib-networking #308666

Closed
Yeshey opened this issue May 3, 2024 · 8 comments · Fixed by #309269
Closed

Comments

@Yeshey
Copy link

Yeshey commented May 3, 2024

Describe the bug

In gnome runs fine, in KDE plasma there are a couple problems:

  • Unable to open file explorer when pressing "+", crashes with error no gsettings schemas are installed on the system
  • Unable to add account, getting error TLS/SSL support not available; install glib-networking

Steps To Reproduce

Run onedriver-launcher in a pure shell:
nix-shell -p onedriver --pure --run onedriver-launcher, use the + and try to use it

OR

  1. have plasma installed and no other desktop environment:
services.xserver.enable = true;
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
  1. Install onedriver from nixpkgs (with home manager for example:)
    home.packages = with pkgs; [ onedriver ];
  1. run onedriver-launcher and press the + button to add a folder.

Expected behavior

No errors

Additional context

we're missing the inputs glib-networking and wrapGAppsHook. wrapGAppsHook should fix the gsettings schemas error (related issue). The TLS/SSL support not available; install glib-networking error requires env variable GIO_EXTRA_MODULES, we should probably wrap onedriver as explained here.

Quick and dirty way to make it work now, without wrapping, is adding those dependencies and adding the GIO_EXTRA_MODULES variable to the whole system:

  1. add glib-networking and wrapGAppsHook to buildInputs and nativeBuildInputs respectively. (not sure which one for either):
# Derivation, not a module!
{ buildGoModule
, fetchFromGitHub
, lib
, pkg-config
, webkitgtk
, glib
, fuse
, installShellFiles
, glib-networking
, wrapGAppsHook
}:
let
  pname = "onedriver";
  version = "0.13.0-2";

  src = fetchFromGitHub {
    owner = "jstaf";
    repo = "onedriver";
    rev = "v${version}";
    hash = "sha256-Bcjgmx9a4pTRhkzR3tbOB6InjvuH71qomv4t+nRNc+w=";
  };
in
buildGoModule {
  inherit pname version src;
  vendorHash = "sha256-OOiiKtKb+BiFkoSBUQQfqm4dMfDW3Is+30Kwcdg8LNA=";

  nativeBuildInputs = [ wrapGAppsHook pkg-config installShellFiles ];
  buildInputs = [ glib-networking webkitgtk glib fuse ];

  ldflags = [ "-X github.com/jstaf/onedriver/cmd/common.commit=v${version}" ];

  subPackages = [
    "cmd/onedriver"
    "cmd/onedriver-launcher"
  ];

  postInstall = ''
    echo "Running postInstall"
    install -Dm644 ./resources/onedriver.svg $out/share/icons/onedriver/onedriver.svg
    install -Dm644 ./resources/onedriver.png $out/share/icons/onedriver/onedriver.png
    install -Dm644 ./resources/onedriver-128.png $out/share/icons/onedriver/onedriver-128.png

    install -Dm644 ./resources/onedriver.desktop $out/share/applications/onedriver.desktop

    mkdir -p $out/share/man/man1
    installManPage ./resources/onedriver.1

    substituteInPlace $out/share/applications/onedriver.desktop \
      --replace "/usr/bin/onedriver-launcher" "$out/bin/onedriver-launcher" \
      --replace "/usr/share/icons" "$out/share/icons"
  '';

  meta = with lib; {
    description = "A network filesystem for Linux";
    longDescription = ''
      onedriver is a network filesystem that gives your computer direct access to your files on Microsoft OneDrive.
      This is not a sync client. Instead of syncing files, onedriver performs an on-demand download of files when
      your computer attempts to use them. onedriver allows you to use files on OneDrive as if they were files on
      your local computer.
    '';
    inherit (src.meta) homepage;
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.massimogengarelli ];
    platforms = platforms.linux;
  };
}
  1. Add to the nixOS configuration the location of the GIO_EXTRA_MODULES variable:
environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.glib-networking.out}/lib/gio/modules" ]; # needed for now for onedriver

We should create a programs.onedriver option eventually ahahha

This is my configuration for the onedriver user service:

    home.packages = with pkgs; [
      myOnedriver
      # onedriver
      # glib-networking
    ];

    # Automount Onedriver
    systemd.user.services = let
      wrapperDir = "/run/wrappers/";
    in {

      #"onedriver@mnt-hdd\\x2dbtrfs-Yeshey-OneDriver" = {
      "onedriver@home-yeshey-OneDriver" = {

        Unit = {
          Description = "onedriver";
        };

        Service = {
          ExecStart = "${pkgs.onedriver}/bin/onedriver ${cfg.onedriverFolder}";
          ExecStopPost = "${wrapperDir}/bin/fusermount -uz ${cfg.onedriverFolder}";
          Restart = "on-abnormal";
          RestartSec = "3";
          RestartForceExitStatus = "2";
        };

        Install = {
          WantedBy = [ "graphical-session.target" ];
        };
      };
    };

Notify maintainers

@massix

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.88, NixOS, 23.11 (Tapir), 23.11.20240501.0638fe2`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11, nixpkgs"`
 - channels(yeshey): `""`
 - nixpkgs: `/etc/nix/path/nixpkgs`

Add a 👍 reaction to issues you find important.

Yeshey added a commit to Yeshey/nixOS-Config that referenced this issue May 3, 2024
@massix
Copy link
Contributor

massix commented May 3, 2024

Hello @Yeshey and thanks for reporting this!

The wrapGAppsHook is already there although it is only available in the unstable channel for now, can you please test if the derivation from nixpkgs-unstable works for you? If not, I will add the missing dependency and make a PR asap :)

As for the GIO_EXTRA_MODULES variable I am not sure there is something I can do at the derivation level.

@Yeshey
Copy link
Author

Yeshey commented May 3, 2024

Hello @Yeshey and thanks for reporting this!

The wrapGAppsHook is already there although it is only available in the unstable channel for now, can you please test if the derivation from nixpkgs-unstable works for you? If not, I will add the missing dependency and make a PR asap :)

As for the GIO_EXTRA_MODULES variable I am not sure there is something I can do at the derivation level.

Thanks @massix, I can confirm the version on the unstable channel doesn't crash with no gsettings schemas are installed on the system, but without the GIO_EXTRA_MODULES variable set the error TLS/SSL support not available; install glib-networking is still present.
I tried to wrap it by adding this line in the end of the postInstall script

wrapProgram "$out/bin/onedriver-launcher" --set GIO_EXTRA_MODULES ${glib-networking.out}/lib/gio/modules

but it didn't fix it, running cat $(which onedriver-launcher) now shows two GIO_EXTRA_MODULES variables set tho

[...]
makeCWrapper '/nix/store/8520msjgyj74wfz8apn89m4bjcc156by-onedriver-0.14.1/bin/.onedriver-launcher-wrapped_' \
    --inherit-argv0 \
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/dykpd7s69f2rfhdjmgc187r3ai0xkpgk-dconf-0.40.0-lib/lib/gio/modules' \
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/xrp3b987wmblhv444xk7aa6v24rgq6am-glib-networking-2.78.0/lib/gio/modules' \
    --set 'GDK_PIXBUF_MODULE_FILE' '/nix/store/r383rvp49gbkv3d7xzgykf1vycickivj-librsvg-2.57.0/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache' \
    --prefix 'XDG_DATA_DIRS' ':' '/nix/store/6ywqswdc2q57mhysnh3jp6dcbxd62yz4-gsettings-desktop-schemas-45.0/share/gsettings-schemas/gsettings-desktop-schemas-45.0:/nix/store/8d431fhwmpfmf9rnpslx8pn98l151wq9-gtk+3-3.24.41/share/gsettings-schemas/gtk+3-3.24.41' \
    --prefix 'XDG_DATA_DIRS' ':' '/nix/store/8520msjgyj74wfz8apn89m4bjcc156by-onedriver-0.14.1/share'
[...]

I'll keep this open for now because of this problem and update the title

the workaround for now is adding environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.glib-networking.out}/lib/gio/modules" ]; to the system configuration

@Yeshey Yeshey changed the title onedriver: doesn't work on KDE plasma onedriver: doesn't work on KDE plasma - TLS/SSL support not available; install glib-networking May 3, 2024
Yeshey added a commit to Yeshey/nixOS-Config that referenced this issue May 3, 2024
Yeshey added a commit to Yeshey/nixOS-Config that referenced this issue May 3, 2024
massix added a commit to massix/nixpkgs that referenced this issue May 5, 2024
@massix
Copy link
Contributor

massix commented May 5, 2024

Hey, I just pushed a small branch which should fix your issue with glib-networking. I built the derivation locally and I get the right GIO_EXTRA_MODULES path set correctly by the wrapGAppsHook3 script.

❯ strings result/bin/onedriver-launcher | grep GIO
GIO_EXTRA_MODULES
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/r2b8ri3mv9py2k1pidnjf40y65zlfdwn-dconf-0.40.0-lib/lib/gio/modules' \
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/c8qxy21xzvz6m3lxggm5w0y2sj40ddyk-glib-networking-2.80.0/lib/gio/modules' \

❯ strings result/bin/onedriver | grep GIO
GIO_EXTRA_MODULES
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/r2b8ri3mv9py2k1pidnjf40y65zlfdwn-dconf-0.40.0-lib/lib/gio/modules' \
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/c8qxy21xzvz6m3lxggm5w0y2sj40ddyk-glib-networking-2.80.0/lib/gio/modules' \

@Yeshey
Copy link
Author

Yeshey commented May 10, 2024

Hey, I just pushed a small branch which should fix your issue with glib-networking. I built the derivation locally and I get the right GIO_EXTRA_MODULES path set correctly by the wrapGAppsHook3 script.

❯ strings result/bin/onedriver-launcher | grep GIO
GIO_EXTRA_MODULES
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/r2b8ri3mv9py2k1pidnjf40y65zlfdwn-dconf-0.40.0-lib/lib/gio/modules' \
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/c8qxy21xzvz6m3lxggm5w0y2sj40ddyk-glib-networking-2.80.0/lib/gio/modules' \

❯ strings result/bin/onedriver | grep GIO
GIO_EXTRA_MODULES
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/r2b8ri3mv9py2k1pidnjf40y65zlfdwn-dconf-0.40.0-lib/lib/gio/modules' \
    --prefix 'GIO_EXTRA_MODULES' ':' '/nix/store/c8qxy21xzvz6m3lxggm5w0y2sj40ddyk-glib-networking-2.80.0/lib/gio/modules' \

In my attempt in my previous comment, I had also tried a method that seemed to have set the correct GIO_EXTRA_MODULES path, but I tried your derivation and still:

image

I grabbed your commit like this and it took a couple hours to build, it seems to have built a lot of programs besides onedriver, I'm still not a great nixOS wizard:

{
  inputs,
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.myHome.onedriver;

  inherit (pkgs.stdenv.hostPlatform) system;
  patchedPkgs = import (fetchTarball {
        url = "https://github.com/NixOS/nixpkgs/archive/4c97436473b756ee6d02e58e43de673d367c73fb.tar.gz";
        sha256 = "sha256:1xnshswwyhnx85mcrc31l8nl0naklfnq8fwfpaa6nxycl65xsw1i";
    }) {
    inherit system;
    config.allowUnfree = true;
  };

  onedriverPackage = patchedPkgs.onedriver;

in
{
  options.myHome.onedriver = with lib; {
    enable = mkEnableOption "onedriver";
    onedriverFolder = mkOption {
      type = types.str;
      example = "/mnt/hdd-btrfs/Yeshey/OneDriver";
    };
    serviceName = mkOption {
      type = types.str;
      example = "onedriver@home-yeshey-OneDriver";
      description = "use `systemd-escape --template [email protected] --path /path/to/mountpoint` to figure out";
    };
  };

  config = lib.mkIf cfg.enable {

    home.packages = [
      onedriverPackage
    ];
onedriver@.service --path ${cfg.onedriverFolder}";
        Unit = {
          Description = "onedriver";
        };

        Service = {
          ExecStart = "${pkgs.onedriver}/bin/onedriver ${cfg.onedriverFolder}";
          # ExecStopPost = "${wrapperDir}/bin/fusermount -uz ${cfg.onedriverFolder}";
          Restart = "on-abnormal";
          RestartSec = "3";
          RestartForceExitStatus = "2";
        };

        Install = {
          WantedBy = [ "graphical-session.target" ];
        };
      };

  };
}

@Yeshey
Copy link
Author

Yeshey commented May 10, 2024

@massix never mind, I'm dumb, forgot to change the package used in ExecStart, now the error doesn't appear, but the window comes up grey?

image

@Yeshey
Copy link
Author

Yeshey commented May 10, 2024

Trying to use the code from your commit in my own config with callPackage gives me

       error: evaluation aborted with the following error message: 'Function called without required argument "wrapGAppsHook3" at /nix/store/yp43zx2bvb3f7qkfy97z4bmri7i1irdx-source/pkgs/onedriver-his.nix:9, did you mean "wrapGAppsHook" or "wrapGAppsHook4"?'

if I use wrapGAppsHook4 instead of wrapGAppsHook3 it works perfectly

@Yeshey
Copy link
Author

Yeshey commented May 10, 2024

using just wrapGAppsHook also works

Yeshey added a commit to Yeshey/nixOS-Config that referenced this issue May 10, 2024
@massix
Copy link
Contributor

massix commented May 11, 2024

Trying to use the code from your commit in my own config with callPackage gives me

       error: evaluation aborted with the following error message: 'Function called without required argument "wrapGAppsHook3" at /nix/store/yp43zx2bvb3f7qkfy97z4bmri7i1irdx-source/pkgs/onedriver-his.nix:9, did you mean "wrapGAppsHook" or "wrapGAppsHook4"?'

if I use wrapGAppsHook4 instead of wrapGAppsHook3 it works perfectly

That is because wrapGAppsHook3 is only on nixos-unstable right now, if you're using nixos-23.11 you need to use wrapGAppsHook, which is the same thing :)

Glad to know the problem has been fixed for you. As for the blank page, it seems to be an upstream issue with onedriver and Plasma 6 (see jstaf/onedriver#398), but since I don't use Plasma I'm afraid I cannot help..

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

Successfully merging a pull request may close this issue.

3 participants