From 18751dd6a4122450cf947be031ecb49680009c82 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sat, 9 Nov 2024 18:16:54 -0500 Subject: [PATCH] firefox with nixGL and vertical tabs --- home/nix/flake.lock | 38 +++++++++++++++++++++++++++++++++++ home/nix/flake.nix | 18 ++++++++++++++++- home/nix/home.nix | 4 +++- home/nix/programs/firefox.nix | 18 +++++++++++++++-- home/nix/programs/nixGL.nix | 31 ++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 home/nix/programs/nixGL.nix diff --git a/home/nix/flake.lock b/home/nix/flake.lock index d608a4c..4e290a2 100644 --- a/home/nix/flake.lock +++ b/home/nix/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -21,6 +36,28 @@ "type": "github" } }, + "nixgl": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713543440, + "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "owner": "nix-community", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1730651795, @@ -40,6 +77,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nixgl": "nixgl", "nixpkgs": "nixpkgs" } } diff --git a/home/nix/flake.nix b/home/nix/flake.nix index 6738db4..e6860c9 100644 --- a/home/nix/flake.nix +++ b/home/nix/flake.nix @@ -8,23 +8,39 @@ # home manager home-manager.url = "github:nix-community/home-manager/release-24.05"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # nixgl + nixgl.url = "github:nix-community/nixGL/310f8e49a149e4c9ea52f1adf70cdc768ec53f8a"; + nixgl.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, home-manager, + nixgl, ... } @ inputs: let inherit (self) outputs; system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; + overlays = [ + nixgl.overlay + ]; in { homeConfigurations."freya" = home-manager.lib.homeManagerConfiguration { inherit pkgs; extraSpecialArgs = {inherit inputs outputs;}; - modules = [./home.nix]; + modules = [ + {nixpkgs.overlays = overlays;} + ./home.nix + { + _module.args = { + inherit nixgl; + }; + } + ]; }; }; } diff --git a/home/nix/home.nix b/home/nix/home.nix index 1971e58..4936ec4 100644 --- a/home/nix/home.nix +++ b/home/nix/home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: { +{ config, pkgs, nixgl, ... }: { imports = [ ./programs @@ -19,6 +19,8 @@ starship discord thunderbird + nixgl.packages.${pkgs.system}.nixGLIntel + nixgl.packages.${pkgs.system}.nixVulkanIntel ]; }; diff --git a/home/nix/programs/firefox.nix b/home/nix/programs/firefox.nix index 560e4ae..3935e18 100644 --- a/home/nix/programs/firefox.nix +++ b/home/nix/programs/firefox.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ pkgs, nixgl, ... }: let lock-false = { Value = false; @@ -8,11 +8,14 @@ Value = true; Status = "locked"; }; + nixGL = import ./nixGL.nix { inherit pkgs nixgl; }; in { programs.firefox = { enable = true; + package = (nixGL pkgs.firefox); + policies = { EnableTrackingProtection = { Value = true; @@ -230,7 +233,7 @@ "media.eme.enabled" = lock-true; # tabs "browser.tabs.inTitlebar" = { - Value = 1; + Value = 0; Status = "locked"; }; "browser.tabs.warnOnClose" = lock-true; @@ -251,6 +254,15 @@ "browser.safebrowsing.downloads.enabled" = lock-true; "browser.safebrowsing.downloads.remote.block_uncommon" = lock-false; "browser.safebrowsing.downloads.remote.block_potentially_unwanted" = lock-false; + # sidebar + "sidebar.revamp" = lock-true; + "sidebar.verticalTabs" = lock-true; + "sidebar.main.tools" = { + Value = ""; + Status = "locked"; + }; + "browser.tabs.closeTabByDblclick" = lock-true; + "ui.key.menuAccessKeyFocuses" = lock-false; }; }; @@ -278,6 +290,8 @@ }; }; userChrome = '' + #sidebar-header { display:none !important; } + #sidebar-search-container { display:none !important; } #firefox-view-button { visibility: collapse; } diff --git a/home/nix/programs/nixGL.nix b/home/nix/programs/nixGL.nix new file mode 100644 index 0000000..9c74fc8 --- /dev/null +++ b/home/nix/programs/nixGL.nix @@ -0,0 +1,31 @@ +{ pkgs, nixgl, ... }: + +let + nixGL = "${nixgl.packages.${pkgs.system}.nixGLIntel}/bin/nixGLIntel"; +in + pkg: + (pkg.overrideAttrs (old: { + name = "nixGL-${pkg.name}"; + buildCommand = '' + set -eo pipefail + + ${ + # Heavily inspired by https://stackoverflow.com/a/68523368/6259505 + pkgs.lib.concatStringsSep "\n" (map (outputName: '' + echo "Copying output ${outputName}" + set -x + cp -rs --no-preserve=mode "${pkg.${outputName}}" "''$${outputName}" + set +x + '') (old.outputs or [ "out" ]))} + + rm -rf $out/bin/* + shopt -s nullglob # Prevent loop from running if no files + for file in ${pkg.out}/bin/*; do + echo "#!${pkgs.bash}/bin/bash" > "$out/bin/$(basename $file)" + echo "exec -a \"\$0\" ${nixGL} $file \"\$@\"" >> "$out/bin/$(basename $file)" + chmod +x "$out/bin/$(basename $file)" + done + shopt -u nullglob # Revert nullglob back to its normal default state + ''; + })) +