I’m trying to configure opensnitch, but having some issues with firefox-esr where ${lib.getBin pkgs.firefox-esr} returns a different nix store path than where my firefox-esr actually runs from.
I think I am running into the exact same issue! I am using LibreWolf instead of Firefox. I configure LibreWolf with Home Manager and what I see is that the store path for LibreWolf in Home Manager is a different store path to what lib.getBin pkgs.librewolf returns so none of my predefined opensnitch rules for LibreWolf work.
I cannot work out how to look up the correct nix store path for LibreWolf. Perhaps it is simple but I haven’t been able to work it out
@mastrboy do you also use Home Manager for configuring Firefox? I wonder if you have the same issue
I tried using librewolf-unwrapped in opensnitch rules but that was a different store path to the one that programs.librewolf produces. I think the default package used by programs.librewolf if you dont set package must be different to pkgs.librewolf or pkgs.librewolf-unwrapped.
Ah, I see what is going on. When you enable a Firefox-derived package via the Home Manager option (as opposed to just chucking it in home.packages, which is what I do), HM adds an additional wrapper on top of what Nixpkgs does. To get at that wrapper package, it seems that you could use config.programs.librewolf.finalPackage.
I have tried config.programs.librewolf.finalPackage in my opensnitch rules but I get the error “error: attribute ‘librewolf’ missing” I use Home Manager via nixos module in my flake based system if that may change the path to refer to the Home Manager version of the package?
I’m not using Home Manager for Firefox and never figured out the underlying issue, so I’m still using regex with wildcards for this in my opensnitch config.
Okay, I see - that is frustrating. I have also been unable to work out how to programmatically get the correct store path for my opensnitch rules.
I have had to resort to setting variables in my nix config to hard coded nix store paths and then referencing those variables in my opensnitch rules. But this means any time those store paths change in the future I will need to manually work out what they new paths are and update those variables…
I think the issue comes from the fact that perhaps both pkgs.firefox-esr and pkgs.librewolf get modified by our configs in some way which means they get a different store path to the pkg in nixpkgs. But I don’t know enough about this stuff yet to know if there is a solution. Surely there is!
For instance, I noticed that if I set the language pack for librewolf in my home manager config then the store path is different again. And the store path both prior and after that change are different from what “lib.getBin pkgs.librewolf” returns!
From a NixOS module (where config refers to your NixOS configuration instead of your HM configuration), you can reference your user’s Home Manager configuration via config.home-manager.users.[username]. So just sticking .programs.librewolf.finalPackage after that should work.
Okay, good to know! In my attempt to get it working 3 days ago, I tried many variations to guess what the correct path was. Tried to use nix repl on my system flake to then see what the path was but was unable to get that to work!
I have tried as you suggest, and it is indeed the solution: