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

Nix(OS) support #130

Closed
RAVENz46 opened this issue Jan 30, 2024 · 8 comments
Closed

Nix(OS) support #130

RAVENz46 opened this issue Jan 30, 2024 · 8 comments

Comments

@RAVENz46
Copy link

RAVENz46 commented Jan 30, 2024

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I made nix derivation to install this to my nixos, however it does not work correctly.
URL link seems not passed to this app, so app open home directory instead of link.

Here is what happened.
Kooha-2024-01-30-19-53-53.webm
And, here is my derivation
{ stdenv
, lib
, fetchzip
, autoPatchelfHook
, makeWrapper
, cairo
, gdk-pixbuf
, gtk3
}:

stdenv.mkDerivation rec {
  pname = "browsers";
  version = "0.5.0";

  src = fetchzip {
    url = "https://github.com/Browsers-software/browsers/releases/download/${version}/browsers_linux.tar.gz";
    hash = "sha256-5BiJ8G77kLlLZr7Ut0jY/hp4zncWsWO55vyCSp6NPqk=";
    stripRoot=false;
  };

  nativeBuildInputs = [
    autoPatchelfHook
    makeWrapper
  ];

  buildInputs = [
    stdenv.cc.cc.lib
    cairo
    gdk-pixbuf
    gtk3
  ];

  installPhase = ''
    mkdir -p $out/{bin,share/applications,lib}
    mv x86_64/${pname} $out/bin
    install -m 444 \
        -D software.Browsers.template.desktop \
        -t $out/share/applications
    substituteInPlace \
        $out/share/applications/software.Browsers.template.desktop \
        --replace 'Exec=€ExecCommand€' 'Exec=${pname}'
    cp -r lib $out
    for size in 16 32 128 256 512; do
      mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
      cp icons/"$size"x"$size"/software.Browsers.png $out/share/icons/hicolor/"$size"x"$size"/apps/software.Browsers.png
    done
  '';

  postFixup = ''
    wrapProgram $out/bin/browsers \
      --prefix LD_LIBRARY_PATH : $out/lib
  '';

  meta = with lib; {
    description = "Open the right browser at the right time";
    homepage = "https://github.com/Browsers-software/browsers";
    changelog = "https://github.com/Browsers-software/browsers/blob/${src.rev}/CHANGELOG.md";
    license = with licenses; [ asl20 mit ];
    maintainers = with maintainers; [ ];
    mainProgram = "browsers";
  };
}

It is possible that I have made a mistake somewhere in my derivation, sorry if I did ....

Describe the solution you'd like
A clear and concise description of what you want to happen.

So, if I didn't make mistake, I hope support NixOS.
I would be more than happy to ship it to nixpkgs.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@liias
Copy link
Contributor

liias commented Jan 30, 2024

Hey there, @RAVENz46, I appreciate that someone does the nix package!

I don't have experience with nix packages, but can see the error in modifiying the .desktop file:
Please change

  --replace 'Exec=€ExecCommand€' 'Exec=${pname}'

to

  --replace '€ExecCommand€' '${pname} %u'

The %u is part of .desktop specification, and is actually placeholder for url that desktop environment substitutes.

@liias
Copy link
Contributor

liias commented Jan 30, 2024

Another issue I can see from the video is that none of the browsers are identified as specific browser types, i.e no browser profiles are shown.

There can be two reasons for that:

  1. <app-binary-dir>/../resources/lib/application-repository.toml is not found (be aware that the "lib" here does not refer to standard linux lib folders, and is just a subdirectory for resource files - I might need to rename it to remove confusion).
  2. .desktop files are not found/named in a standard way for the other browsers

@RAVENz46
Copy link
Author

Hey there, @RAVENz46, I appreciate that someone does the nix package!

I don't have experience with nix packages, but can see the error in modifiying the .desktop file: Please change

  --replace 'Exec=€ExecCommand€' 'Exec=${pname}'

to

  --replace '€ExecCommand€' '${pname} %u'

The %u is part of .desktop specification, and is actually placeholder for url that desktop environment substitutes.

Yes! Now, link correctly passed.

Another issue I can see from the video is that none of the browsers are identified as specific browser types, i.e no browser profiles are shown.

There can be two reasons for that:

1. `<app-binary-dir>/resources/lib/application-repository.toml` is not found (be aware that the "lib" here does not refer to standard linux lib folders, and is just a subdirectory for resource files - I might need to rename it to remove confusion).

2. `.desktop` files are not found/named in a standard way for the other browsers

I'm still beginner of nix, so IDK how/able to fix these.
Anyway, I'm fine with it so I close this issue. Thank you!

@RAVENz46
Copy link
Author

RAVENz46 commented Jan 30, 2024

I changed $out/lib to $out/resources/lib then, it seems work cause chromium and firefox's name placed bit higher.

Screenshot from 2024-01-31 00-01-38

Final result
{ stdenv
, lib
, fetchzip
, autoPatchelfHook
, cairo
, gdk-pixbuf
, gtk3
}:

stdenv.mkDerivation rec {
  pname = "browsers";
  version = "0.5.0";

  src = fetchzip {
    url = "https://github.com/Browsers-software/browsers/releases/download/${version}/browsers_linux.tar.gz";
    hash = "sha256-5BiJ8G77kLlLZr7Ut0jY/hp4zncWsWO55vyCSp6NPqk=";
    stripRoot=false;
  };

  nativeBuildInputs = [
    autoPatchelfHook
  ];

  buildInputs = [
    stdenv.cc.cc.lib
    cairo
    gdk-pixbuf
    gtk3
  ];

  installPhase = ''
    mkdir -p $out/{bin,share/applications,resources}
    mv x86_64/${pname} $out/bin
    install -m 444 \
        -D software.Browsers.template.desktop \
        -t $out/share/applications
    substituteInPlace \
        $out/share/applications/software.Browsers.template.desktop \
        --replace 'Exec=€ExecCommand€' 'Exec=${pname} %u'
    cp -r lib $out/resources
    for size in 16 32 128 256 512; do
      mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
      cp icons/"$size"x"$size"/software.Browsers.png $out/share/icons/hicolor/"$size"x"$size"/apps/software.Browsers.png
    done
  '';

  meta = with lib; {
    description = "Open the right browser at the right time";
    homepage = "https://github.com/Browsers-software/browsers";
    changelog = "https://github.com/Browsers-software/browsers/blob/${src.rev}/CHANGELOG.md";
    license = with licenses; [ asl20 mit ];
    maintainers = with maintainers; [ ];
    mainProgram = "browsers";
  };
}

@liias
Copy link
Contributor

liias commented Jan 30, 2024

I corrected my previous comment about resources location. So the tree should be basically like this:

/usr/share/software.Browsers/
  ├─ bin/
  │  └─ browsers
  └─ resources/
     ├─ i18n/en-US/builtin.ftl
     ├─ icons/512x512/software.Browsers.png
     └─ lib/application-repository.toml

It's also safe to add symlink to the binary if you need it somewhere else.

I can see in your screenshot, that profile names are still not shown, so likely something is still missing (also need to refresh apps from the 3-dot menu).

@RAVENz46
Copy link
Author

Thanks again for all your help.
I add i18n directory, now settings and browser profile seems fine.
Icon directory may be unnecessary under resourses dir, this is because nix specific thing.
But I found something should fix, so let me ask you.

  1. launching browsers from .desktop, dock icon work however, from command line, launcher like rofi and clicking link, dock icon not display( You can see in video).
  2. Browsers appear inside of Browsers(you can also see it in video). However, there are no settings to hide options. This option is not available on linux or my fault?
Kooha-2024-01-31-11-41-41.webm

@liias
Copy link
Contributor

liias commented Jan 31, 2024

Thanks again for all your help. I add i18n directory, now settings and browser profile seems fine. Icon directory may be unnecessary under resourses dir, this is because nix specific thing. But I found something should fix, so let me ask you.

Awesome! Only the 512x512 icon is used under resources dir actually, to be shown in About dialog.
FYI, be aware, that in next release resources/lib/ will be renamed to resources/repository/

  1. launching browsers from .desktop, dock icon work however, from command line, launcher like rofi and clicking link, dock icon not display( You can see in video).

Actually, it's designed that dock icon would never be shown (like when you right click or alt+tab, you don't see icons for those dialogs), hopefully the fact that it is shown is small enough to ignore for now ;)

  1. Browsers appear inside of Browsers(you can also see it in video).

There's a very simple filter right now - if the .desktop file is named as software.Browsers.desktop, then it will skip it from the list.

However, there are no settings to hide options. This option is not available on linux or my fault?

Bad design from my side - you need to right click with your mouse on the browser and click "Hide"

@RAVENz46
Copy link
Author

Okay, now almost everything fine.
Thanks!!!

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

No branches or pull requests

2 participants