nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.15k stars 1.85k forks source link

Firefox: Import HTML file of bookmarks #4885

Open D3vil0p3r opened 10 months ago

D3vil0p3r commented 10 months ago

Description

For users having hundreds of bookmarks to import can be very heavy to write them manually in nix file. Can you add the possibility in firefox module for HM to import HTML bookmark file in Firefox?

ghost commented 8 months ago

I think I may have found a solution for this! A minimal example:

    programs.firefox = {
      enable = true;

      profiles.bex = {
        settings = {
          "browser.bookmarks.file" = "/home/bex/.dotfiles/nixos/modules/home-manager/firefox/bookmarks.html";
          "browser.places.importBookmarksHTML" = true;
        };
      };
    };

I'm assuming there's a better way of getting the user's home directory in Nix, but I had some trouble and the absolute path worked. (I'm very new at Nix/NixOS/Home Manager.)

Edit: I'm assuming this will replace your bookmarks on every rebuild, so you have to be careful to re-export them if any changes are made.

sumnerevans commented 7 months ago

You can use config.home.homeDirectory to reference the user's home directory.

You could probably also reference the bookmarks path directly like:

"browser.bookmarks.file" = ./relative/path/to/bookmarks.html;

which will put it into the nix store (which you may or may not want). Also, Firefox might get mad if it can't write to the bookmarks file.

ghost commented 7 months ago

Ah, I'll give that one a go, thanks!

As for the relative path, it actually puts it in the store with a full path, if you skip the quotes around the path. The problem there is that the generated user.js then contains something like this:

user_pref("browser.bookmarks.file", "\"/nix/store/3rbwiydh7hwykzwiyq3wsf34n4zhyvni-bookmarks.html\"");

Notice the escaped quotes within quotes, doesn't work, Firefox refuses to load them. I'm guessing this is some bug in the programs.firefox-module of Home Manager, will look in to it some more and add a bug report for it.

stale[bot] commented 4 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.