bandithedoge / nixpkgs-firefox-darwin

Nixpkgs overlay with Firefox binary builds for macOS
51 stars 6 forks source link

Support Policies #7

Open shishkin opened 9 months ago

shishkin commented 9 months ago

Thanks for providing this overlay. I've used it to install Firefox via Home Manager programs.firefox and it mostly worked. One issue I had is that this package seem to ignore policies option. The nixpkgs version does place the policies.json file inside the package: https://github.com/NixOS/nixpkgs/blob/nixpkgs-23.11-darwin/pkgs/applications/networking/browsers/firefox-bin/default.nix#L107-L109. According to Mozilla the file should be written to Firefox.app/Contents/Resources/distribution. Would it make sense to support policies in this overlay?

themg95 commented 9 months ago

I have also come across the same issue and created a band-aid solution for it

final: prev: {
  firefox-darwin = prev.firefox-bin.overrideAttrs (previousAttrs: {
    postInstall = ''
      folder="''${out}/Applications/Firefox.app/Contents/Resources/distribution"
      mkdir -p "''${folder}"

      touch "''${folder}/policies.json"

      echo '{
      "policies": {
        "DisableAppUpdate": true,
        "AppAutoUpdate": false,
        "ExtensionUpdate": false,
        "EncryptedMediaExtensions": {
          "Enabled": false
        }
      }
      }' > "''${folder}/policies.json"
    ''; 
  });
}
bjeanes commented 1 month ago

Could it be home-manager which is not applying the policies? https://github.com/nix-community/home-manager/blob/1bbc1a5a1f4de7401c92db85b2119ed21bb4139d/modules/programs/firefox.nix#L205-L206

bjeanes commented 1 month ago

It is also possible to set policies in macOS with the defaults command, which home-manager supports directly, however this feels less "pure" in the sense that if you removed a policy entry, I don't think it would revert it to FF default...