# modules/home/floorp.nix — Floorp, themed with ShyFox. Zen is the default # browser now (modules/home/zen.nix owns xdg.mimeApps and $BROWSER); Floorp # stays installed with its profile and bookmarks. # # The profile is written by hand under ~/.config/floorp (Floorp 12's location) # rather than through `programs.floorp.profiles.*`: home-manager's Floorp module # still targets ~/.floorp (Floorp 11), so anything set there is ignored without # an error. `programs.floorp.enable` below is used for the package only. # # The private parts are sops secrets, not Nix (see .sops.yaml): # secrets/floorp/user.js every pref, placed at /user.js by # sops-nix at login and on every switch # secrets/floorp/bookmarks.html the bookmarks export Floorp imports once, on a # fresh profile (browser.bookmarks.file in user.js) # Edit either with `TMPDIR=/dev/shm sops secrets/floorp/`, then # `nh os switch` and restart Floorp, which reads user.js only at startup. # Saved passwords, cookies, history and sessions are written by Floorp into the # profile and are never in this repo. # # The theme is ShyFox, vendored from the gitlab.com/DAEMON-404/ShyFox fork # (synced at 6b69ed8, which fixes Gecko 157) into _shyfox/ and linked as # /chrome. To pull a newer fork: rsync its chrome/ over _shyfox/ # excluding userChrome.css and userContent.css. `/_` keeps the asset tree out of # import-tree's reach (see flake.nix). { ... }: { flake.homeModules.floorp = { config, lib, pkgs, ... }: let profile = "shyfox"; profileDir = "floorp/${profile}"; previousProfile = "1il5n65w.default"; # kept, not default ##### Extensions ############################################################ # ShyFox needs both of these: Sidebery provides the sidebar the theme is # built around, and Userchrome Toggle Extended (by Naezr, who writes ShyFox) # binds the toggle. Each file has to be named for the add-on's own ID. # `extensions.startupScanScopes`/`autoDisableScopes` in user.js are # what make a profile-dropped add-on come up enabled instead of parked as a # disabled sideload. extensions = { "{3c078156-979c-498b-8990-85f7987dd929}" = pkgs.fetchurl { name = "sidebery-5.6.1.xpi"; url = "https://addons.mozilla.org/firefox/downloads/file/4903712/sidebery-5.6.1.xpi"; sha256 = "e8a0a4b556ab7dd536897c1816af9d0918030223068ea6683a04376103a6caf2"; }; "userchrome-toggle-extended@n2ezr.ru" = pkgs.fetchurl { name = "userchrome_toggle_extended-2.0.1.xpi"; url = "https://addons.mozilla.org/firefox/downloads/file/4341014/userchrome_toggle_extended-2.0.1.xpi"; sha256 = "3f5be2684284c0b79aaad0f70872a87f21a9a1329a5eaf8e60090e6f0e6a741d"; }; }; in { # The package only — see the header for why the profile is not built with # `programs.floorp.profiles.*`. programs.floorp.enable = true; # Every pref (start page, fonts, ShyFox options, Floorp's design settings and # switched-off extras) as one encrypted file, symlinked to where Floorp reads it. sops.secrets."floorp-user.js" = { sopsFile = ../../secrets/floorp/user.js; format = "binary"; path = "${config.xdg.configHome}/${profileDir}/user.js"; }; # The bookmarks export, at ~/.config/sops-nix/secrets/floorp-bookmarks.html. sops.secrets."floorp-bookmarks.html" = { sopsFile = ../../secrets/floorp/bookmarks.html; format = "binary"; }; xdg.configFile = { # Written here rather than left to Floorp so the themed profile is the # default. The trade-off: profile changes made in Floorp's own UI are # reverted on the next `nh os switch`. "floorp/profiles.ini".text = '' [Profile0] Name=${profile} IsRelative=1 Path=${profile} Default=1 [Profile1] Name=default IsRelative=1 Path=${previousProfile} [General] StartWithLastProfile=1 Version=2 ''; # The whole theme tree, read-only out of the store. To change the CSS, # edit modules/home/floorp/_shyfox/ and rebuild. wallpaper.png and # wallpaper-light.png are the new-tab backgrounds ShyFox's new-tab CSS # references; replace either file to change them. "${profileDir}/chrome".source = ./floorp/_shyfox; } // lib.mapAttrs' (id: xpi: lib.nameValuePair "${profileDir}/extensions/${id}.xpi" { source = xpi; }) extensions; # One-time bookmark import. # # `browser.places.importBookmarksHTML` is the pref that makes Firefox read # browser.bookmarks.file into the places database. It cannot live in user.js: # Firefox consumes it and sets it back to false, but user.js re-applies # every pref at every startup, so the import would run again on each launch # and duplicate every bookmark. Seeding it into prefs.js instead, only while # the profile has no places.sqlite yet, imports once on first launch and # never again. home.activation.floorpSeedBookmarkImport = lib.hm.dag.entryAfter [ "writeBoundary" ] '' floorpProfile="${config.xdg.configHome}/${profileDir}" floorpPrefs="$floorpProfile/prefs.js" if [ ! -e "$floorpProfile/places.sqlite" ] \ && ! grep -qs 'browser.places.importBookmarksHTML' "$floorpPrefs"; then verboseEcho "Floorp: seeding the one-time bookmark import in $floorpPrefs" if [ -z "''${DRY_RUN:-}" ]; then mkdir -p "$floorpProfile" printf '%s\n' 'user_pref("browser.places.importBookmarksHTML", true);' >> "$floorpPrefs" fi fi ''; } ; }