about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-02-02 08:51:02 -0800
committerFranck Cuny <franck@fcuny.net>2024-02-02 08:53:16 -0800
commit16545ae411aa886e94be0deaae79e07f39b9adfb (patch)
tree890d35ae99c9aa397d34baf4607853760f5098dd
parentrun CI commands in a nix shell (diff)
downloadworld-16545ae411aa886e94be0deaae79e07f39b9adfb.tar.gz
install firefox
The firefox packages for darwin are broken.
`bandithedoge/nixpkgs-firefox-darwin` provides an overlay to install
the package on darwin.

Add some specific configurations to make firefox work as I want out of
the box.

We also add NUR to install some firefox extensions (ublock, 1password).
-rw-r--r--flake.lock37
-rw-r--r--flake.nix7
-rw-r--r--flake/hosts.nix13
-rw-r--r--home/darwin.nix1
-rw-r--r--home/dev.nix1
-rw-r--r--home/firefox.nix81
-rw-r--r--home/git.nix3
-rw-r--r--hosts/mba/default.nix3
8 files changed, 143 insertions, 3 deletions
diff --git a/flake.lock b/flake.lock
index 3577c7c..a41d989 100644
--- a/flake.lock
+++ b/flake.lock
@@ -39,6 +39,26 @@
         "type": "github"
       }
     },
+    "firefox-darwin": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1706834474,
+        "narHash": "sha256-C5jaUZAx9Y04LwLdMk8QqA6Qw4Oe8MugPajjxJxInvs=",
+        "owner": "bandithedoge",
+        "repo": "nixpkgs-firefox-darwin",
+        "rev": "61c35a7992e8a540571ae21459f1c6b1c084a773",
+        "type": "github"
+      },
+      "original": {
+        "owner": "bandithedoge",
+        "repo": "nixpkgs-firefox-darwin",
+        "type": "github"
+      }
+    },
     "flake-compat": {
       "flake": false,
       "locked": {
@@ -235,6 +255,21 @@
         "type": "github"
       }
     },
+    "nur": {
+      "locked": {
+        "lastModified": 1706841886,
+        "narHash": "sha256-gT98Myel/I4COZqwaYKs8HiaPYmPdL0i6uKsIJyCBpA=",
+        "owner": "nix-community",
+        "repo": "NUR",
+        "rev": "55de3834d91a4fe68ba2b54253827546d20de133",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "NUR",
+        "type": "github"
+      }
+    },
     "pre-commit-hooks": {
       "inputs": {
         "flake-compat": "flake-compat",
@@ -263,10 +298,12 @@
       "inputs": {
         "darwin": "darwin",
         "devshell": "devshell",
+        "firefox-darwin": "firefox-darwin",
         "flake-parts": "flake-parts",
         "futils": "futils",
         "home-manager": "home-manager",
         "nixpkgs": "nixpkgs_2",
+        "nur": "nur",
         "pre-commit-hooks": "pre-commit-hooks",
         "treefmt-nix": "treefmt-nix"
       }
diff --git a/flake.nix b/flake.nix
index 93df93c..321b657 100644
--- a/flake.nix
+++ b/flake.nix
@@ -19,6 +19,13 @@
       inputs.nixpkgs.follows = "nixpkgs";
     };
 
+    firefox-darwin = {
+      url = "github:bandithedoge/nixpkgs-firefox-darwin";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+
+    nur = { url = "github:nix-community/NUR"; };
+
     pre-commit-hooks = {
       url = "github:cachix/pre-commit-hooks.nix";
       inputs.nixpkgs.follows = "nixpkgs";
diff --git a/flake/hosts.nix b/flake/hosts.nix
index 9ec9d1b..7fc0612 100644
--- a/flake/hosts.nix
+++ b/flake/hosts.nix
@@ -1,12 +1,21 @@
 { inputs, ... }:
 let
-  inherit (inputs) nixpkgs darwin home-manager;
+  inherit (inputs) nixpkgs darwin home-manager firefox-darwin nur;
   inherit (nixpkgs.lib) mkMerge;
 
   mkDarwinConfig = system: path:
     darwin.lib.darwinSystem {
       inherit system;
-      modules = [ home-manager.darwinModule path ];
+      modules = [
+        home-manager.darwinModule
+        path
+        {
+          nixpkgs.overlays = [
+            firefox-darwin.overlay
+            nur.overlay
+          ];
+        }
+      ];
       specialArgs = { inherit inputs; };
     };
 in
diff --git a/home/darwin.nix b/home/darwin.nix
index 17eecd0..defd381 100644
--- a/home/darwin.nix
+++ b/home/darwin.nix
@@ -4,6 +4,7 @@
 
   imports = [
     ./dev.nix
+    ./firefox.nix
     ./git.nix
     ./ssh.nix
     ./zsh.nix
diff --git a/home/dev.nix b/home/dev.nix
index 16227ad..0c35380 100644
--- a/home/dev.nix
+++ b/home/dev.nix
@@ -30,7 +30,6 @@ in
     pythonEnv
 
     google-cloud-sdk
-
   ];
 
   home.sessionPath = [
diff --git a/home/firefox.nix b/home/firefox.nix
new file mode 100644
index 0000000..2710f91
--- /dev/null
+++ b/home/firefox.nix
@@ -0,0 +1,81 @@
+{ pkgs, ... }: {
+  programs.firefox = {
+    enable = true;
+    package = pkgs.firefox-bin;
+    profiles.default = {
+      isDefault = true;
+      extensions = with pkgs.nur.repos.rycee.firefox-addons; [
+        ublock-origin
+        onepassword-password-manager
+      ];
+      bookmarks = [
+        {
+          name = "GitHub Notifications";
+          keyword = "n";
+          url = "https://github.com/notifications?query=is%3Aunread";
+        }
+        {
+          name = "GitHub Pull Requests";
+          keyword = "p";
+          url = "https://github.com/pulls";
+        }
+      ];
+      search = {
+        default = "DuckDuckGo";
+        engines = {
+          "Nix Packages" = {
+            urls = [
+              {
+                template = "https://search.nixos.org/packages";
+                params = [
+                  {
+                    name = "type";
+                    value = "packages";
+                  }
+                  {
+                    name = "query";
+                    value = "{searchTerms}";
+                  }
+                ];
+              }
+            ];
+            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
+            definedAliases = [ "np" ];
+          };
+          "Google".metaData.hidden = true;
+          "Amazon.com".metaData.hidden = true;
+          "Bing".metaData.hidden = true;
+          "DuckDuckGo".metaData.hidden = true;
+          "eBay".metaData.hidden = true;
+          "Wikipedia (en)".metaData.alias = "w";
+        };
+        force = true;
+      };
+      settings = {
+        "app.update.auto" = false;
+
+        "browser.shell.checkDefaultBrowser" = false;
+        "browser.contentblocking.category" = "strict";
+        "browser.newtabpage.enabled" = false; # Make new tabs blank
+        "browser.startup.page" = 3; # Restore previous windows and tabs on startup.
+        "browser.warnOnQuit" = false;
+
+        "dom.forms.autocomplete.formautofill" = false; # Disable autofill
+
+        "extensions.formautofill.creditCards.enabled" = false; # Disable credit cards
+        "extensions.htmlaboutaddons.inline-options.enabled" = false;
+        "extensions.htmlaboutaddons.recommendations.enabled" = false;
+        "extensions.pocket.enabled" = false;
+        "extensions.pocket.showHome" = false;
+
+        # Disable Sponsored Top Sites
+        "services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsoredTopSite" = false;
+
+        "network.http.referer.spoofSource" = true;
+
+        "privacy.donottrackheader.value" = 1;
+        "privacy.donottrackheader.enabled" = true;
+      };
+    };
+  };
+}
diff --git a/home/git.nix b/home/git.nix
index 2c69c64..4fbbbb9 100644
--- a/home/git.nix
+++ b/home/git.nix
@@ -33,6 +33,9 @@ in
       # abort if the remote branch does not match the local one
       push.default = "simple";
 
+      # https://adamj.eu/tech/2024/01/18/git-improve-diff-histogram/
+      diff.algorithm = "histogram";
+
       init.defaultBranch = "main";
 
       pull.rebase = true;
diff --git a/hosts/mba/default.nix b/hosts/mba/default.nix
index ad84035..04d6066 100644
--- a/hosts/mba/default.nix
+++ b/hosts/mba/default.nix
@@ -9,6 +9,9 @@
     };
   };
 
+  # in order to install things like 1password's extensions
+  nixpkgs.config.allowUnfree = true;
+
   programs.zsh.enable = true;
 
   # Required for homebrew on aarch64