Home manager merge firefox bookmark and profile settings

I’m attempting to split out bookmark management into multiple files for readability and managing multiple accounts, but am not sure how to do that. Technically my config here uses librewolf, but since the program is derived from Firefox, that shouldn’t change anything.

Faulty example
#nix bookmarks.nix
{config, pkgs, ... }:
{
  programs.librewolf.profiles.defualt.bookmarks = {
    force = true;
    settings = [
      { name = "NixOS";
        bookmarks = [
      	  { name = "packages";
       	    url = "";
       	  }
        ];
      }
    ];
  };
}
#game bookmarks.nix
{config, pkgs, ... }:

{
  programs.librewolf.profiles.defualt.bookmarks = {
    force = true;
    settings = [
      { name = "Games";
        bookmarks = [
      	  { name = "Puzzlescript";
      	    url = "https://www.puzzlescript.net/";
      	  }
        ];
      }
    ];
  };
}
#home.nix
{confic, pkgs, ...}:

{
  users.admin = { pkgs, ...}: {
    programs.librewolf = {
      enable = true;
    };
    imports = [
      (./. + "/nix bookmarks.nix")
    ];
  };

  users.fluff = { pkgs, ...}: {
    programs.librewolf = {
      enable = true;
    };
    imports = [
      (./. + "/nix bookmarks.nix")
      (./. + "/game bookmarks.nix")
    ];
  };
}

I’ve also tried to use imports within the bookmarks.settings field, but that just lead to type errors on the list of sub-modules.

My best guess on how this could be solved is some form of type casting, list manipulation, or just brute force with concatenating as strings and evaluating. Regardless, as someone just getting into NixOS, it seems impossible to find resources for any of that.

Edit: the reproduction steps here were untested and don’t work. Please see Home manager merge firefox bookmark and profile settings - #4 by Fluff for files to reproduce the error.

Is that an actual space in the filename? That seems inadvisable.

That aside, your config looks correct (except for presumably misspelling default), what’s not working?

1 Like

Also confic.

But yeah, I agree with @TLATER; this general approach should work. If the typos aren’t the problem, post real files and real errors please.

2 Likes

Digging back into the problem with fresh eyes, it does seem like I haven’t done my due diligence properly. With some more testing, I’ve gotten the error down to a proper minimal working example. It seems like the issue isn’t between the bookmark files at all, but rather between the bookmark file and profile settings.

code and error
# home.nix
{ config, pkgs, ... }:

{
  home-manager = {

    useGlobalPkgs = true;
    users.fluff = { pkgs, ... }: {
      programs.librewolf = {
        enable = true;
     	profiles.default = {
     	  settings = {
     	    "privacy.fingerprintingProtection"=true;
     	    "privacy.resistFingerprinting"=false;
     	  };
     	};
      };
	  imports = [
	    (./. + "/admin_bookmarks.nix")
	  ];
      home.stateVersion = "25.11";
    };
  };
}

# admin_bookmarks.nix
{ config, pkgs, ... }:

{
  programs.librewolf.profiles.defualt.bookmarks = {
    force = true;
    settings = [
      { name = "NixOS";
        bookmarks = [
      	  { name = "packages";
      	    url = "https://search.nixos.org/packages";
      	  }
        ];
      }
    ];
  };
}

building the system configuration...
error:
       … while calling the 'head' builtin
         at /nix/store/h38417wn715s107d3ihxkskzsj7pa666-source/lib/attrsets.nix:1696:13:
         1695|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1696|             head values
             |             ^
         1697|           else

       … while evaluating the attribute 'value'
         at /nix/store/h38417wn715s107d3ihxkskzsj7pa666-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/h38417wn715s107d3ihxkskzsj7pa666-source/nixos/modules/system/activation/top-level.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error:
       Failed assertions:
       - fluff profile: Must have exactly one default LibreWolf profile but found 2, namely default, defualt
       - fluff profile: Must not have a LibreWolf profile with an existing ID but
         - ID 0 is used by default, defualt
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel --dry-run' returned non-zero exit status 1.

It tells you the problem. You still have a typo (default vs defualt)

1 Like

defualt seems to be created as a second profile instead of being merged with the(!) default profile in the first place aka as declared in users.fluff.programs.librewolf.profiles, being ““true if profile ID is 0”“ (isDefault) in comparison to the log you appended, see ?

1 Like

Sorry for still missing it. thanks for your patience in helping me find what’s ultimately a typo.

1 Like