nix-community / home-manager

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

bug: importing a bookmarks.html can't be in nix store #5219

Open rebeccasaurus opened 2 months ago

rebeccasaurus commented 2 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

Okay, so, I'm trying to import a lot of bookmarks into Firefox. Works fine with something like this:

    programs.firefox = {
      enable = true;

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

But, if I change the path to a, well path, instead of a string, no matter if relative or full, the resulting user.js contains the following:

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

Notice the escaped quotation marks inside the quotation marks, Firefox will fail to import that file. Works fine if it's a string though, but it has the full path to my dotfiles-folder, not the Nix store, which feels very.. un-Nixy.

Not sure if this is maybe a Nix-issue, path to string conversion or something? I've tried looking in home-manager/modules/programs/firefox.nix but I'm so new to this whole ecosystem/language I couldn't quite figure out where the error was.

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.6.22, NixOS, 24.05 (Uakari), 24.05.20240325.57e6b3a`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - nixpkgs: `/nix/store/161i7cxz0w0raqmrj88z86cj66babp9z-source`
alyraffauf commented 3 days ago

Late to this, but just ran across some issues here myself. If you use string interpolation with a relative path, it should work. consider this:

    programs.firefox = {
      enable = true;

      profiles.username = {
        settings = {
          "browser.bookmarks.file" = "${./bookmarks.html}";
          "browser.places.importBookmarksHTML" = true;
        };
      };
    };

This assumes your .nix file and your bookmarks.html are in the same directory, of course. Adjust as necessary.

Here's my implementation: https://github.com/alyraffauf/nixcfg/blob/e829a2d4f85651d9fcf6fc9c884caf5c3a4523d1/homes/aly/firefox/default.nix#L22