Repository: nix-community/home-manager

Issue #3698: bug: search.json.mozlz4 symlink being replaced by file
Created: 2023-02-23T14:46:16Z
Are you following the right branch?

 My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

 I have searched the existing issues

Issue description
Firefox causes home-manager to fail restarting.
After restarting Firefox, the search.json.mozlz4 symlink is replaced by a file. This causes the home-manager to fail with:
Existing file '/home/[user]/.mozilla/firefox/default/search.json.mozlz4' is in the way of '/nix/store/[hash]-home-manager-files/.mozilla/firefox/default/search.json.mozlz4'
Please move the above files and try again or use 'home-manager switch -b backup' to back up existing files automatically.

I use home-manager as a module in NixOS. The home-manager command is thus not available, and nixos-rebuild switch --flake does not have a -b backup flag. The only way out is indeed to manually remove search.json.mozlz4. Then the symlink is re-created.
NixOS 22.11.20230222.c95bf18 (Raccoon)
Home-manager rev 2cb27c7
Maintainer CC
@rycee @kira-bruneau
System information
- system: `"x86_64-linux"`
 - host os: `Linux 6.1.12, NixOS, 22.11 (Raccoon), 22.11.20230222.c95bf18`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Duplicate issue #5726: bug: HM backups its own generated files
Created: 2024-08-12T00:36:48Z
Are you following the right branch?

 My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

 I have searched the existing issues

Issue description
I'm using the home-manager firefox module and defined some custom search engines like so:

  Config Snippet
  programs.firefox.profiles.<name>.search = {
    default = "startpage";
    privateDefault = "startpage";
    engines = {
      startpage = {
        id = "startpage@nixos";
        urls = [
          {
            template = "https://www.startpage.com/do/search?prfe=e48b2e857307fd3c8072f11ae90083fcc78ab18567a5d00b50dfaed8f9a2b466eb09282fff5fb1bd0adb8040720e12b4f058c54302528ca52d20b7c08b2d5d66a86f205976ef4a656670b7b2";
            params = [
              {
                name = "query";
                value = "{searchTerms}";
              }
            ];
          }
        ];

        definedAliases = [
          "@startpage"
          "@st"
        ];
      };
      "Nix Packages" = {
        id = "np@nixos";
        urls = [
          {
            template = "https://search.nixos.org/packages";
            params = [
              {
                name = "type";
                value = "packages";
              }
              {
                name = "channel";
                value = "unstable";
              }
              {
                name = "query";
                value = "{searchTerms}";
              }
            ];
          }
        ];

        icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
        definedAliases = [ "@np" ];
      };
      "NixOs Options" = {
        id = "no@nixos";
        urls = [
          {
            template = "https://search.nixos.org/options";
            params = [
              {
                name = "channel";
                value = "unstable";
              }
              {
                name = "query";
                value = "{searchTerms}";
              }
            ];
          }
        ];

        icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
        definedAliases = [ "@no" ];
      };
      "HM Options" = {
        id = "hm@nixos";
        urls = [
          {
            template = "https://home-manager-options.extranix.com";
            params = [
              {
                name = "release";
                value = "master";
              }
              {
                name = "query";
                value = "{searchTerms}";
              }
            ];
          }
        ];

        definedAliases = [ "@hm" ];
      };
      "Noogle" = {
        id = "nog@nixos";
        urls = [
          {
            template = "https://noogle.dev/q";
            params = [
              {
                name = "term";
                value = "{searchTerms}";
              }
            ];
          }
        ];

        definedAliases = [ "@nog" ];
      };
    };
  };

Now I'm facing an issue where sometimes (ca. 40%) when I rebuild home-manager backups a file named search.json.mozlz4 in ~/.mozilla/firefox/<profile-name>. This file was generated by home-manager so I'm not sure why it does that. But when comparing the two files they are identical, so I'm wondering why home-manager even tries to create a backup.
This gets really annoying as I have to delete this file on a regular basis.
Maintainer CC
No response
System information
- system: `"x86_64-linux"`
 - host os: `Linux 6.6.44, NixOS, 24.11 (Vicuna), 24.11.20240804.cb9a96f`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - nixpkgs: `/nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source`

Closing comment (2024-08-20T20:02:18Z): Oh yep this is a duplicate of #3698. It sounds like you need to use the force option like @brckd mentioned.
This is pretty easy to forget though and isn't that discoverable if you don't look through the docs. I was planning on refactoring the search submodule to require an enable option instead of force: #5697 (comment), but I was still waiting on that first PR to be merged.