Skip to content

Nix(OS) support #130

Closed
Closed

Description

@RAVENz46

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.

Activity

  1. liias commented on Jan 30, 2024

    @liias
    Contributor

    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.

  2. liias commented on Jan 30, 2024

    @liias
    Contributor

    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
  3. RAVENz46 commented on Jan 30, 2024

    @RAVENz46
    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!

  4. RAVENz46 commented on Jan 30, 2024

    @RAVENz46
    Author

    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";
      };
    }
    
  5. liias commented on Jan 30, 2024

    @liias
    Contributor

    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).

  6. RAVENz46 commented on Jan 31, 2024

    @RAVENz46
    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
  7. liias commented on Jan 31, 2024

    @liias
    Contributor

    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"

  8. RAVENz46 commented on Jan 31, 2024

    @RAVENz46
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Browser

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions