From 1c632d6245d2b84dd09aa483f8742840885ec87a Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 3 Jan 2025 09:21:31 -0500 Subject: [PATCH] refactor nix a bit --- home/nix/flake.nix | 26 +++---- home/nix/home.nix | 18 ++--- home/nix/programs/default.nix | 5 -- home/nix/programs/firefox.nix | 111 ++++++++++++++++++++--------- home/nix/programs/home-manager.nix | 7 ++ home/nix/programs/nix-ld.nix | 15 ++++ 6 files changed, 118 insertions(+), 64 deletions(-) delete mode 100644 home/nix/programs/default.nix create mode 100644 home/nix/programs/home-manager.nix create mode 100644 home/nix/programs/nix-ld.nix diff --git a/home/nix/flake.nix b/home/nix/flake.nix index e1f3527..3e2afb1 100644 --- a/home/nix/flake.nix +++ b/home/nix/flake.nix @@ -15,31 +15,31 @@ }; outputs = { - self, nixpkgs, home-manager, nixgl, ... - } @ inputs: let - inherit (self) outputs; + }: + let system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - overlays = [ - nixgl.overlay - ]; + username = "freya"; in { - homeConfigurations."freya" = + homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = {inherit inputs outputs;}; + pkgs = nixpkgs.legacyPackages.${system}; modules = [ - {nixpkgs.overlays = overlays;} ./home.nix - { + ({ _module.args = { inherit nixgl; }; - } + nixpkgs.overlays = [ nixgl.overlay ]; + home = { + inherit username; + homeDirectory = "/home/${username}"; + stateVersion = "25.05"; + }; + }) ]; }; }; diff --git a/home/nix/home.nix b/home/nix/home.nix index 5870794..c4ee304 100644 --- a/home/nix/home.nix +++ b/home/nix/home.nix @@ -1,19 +1,17 @@ -{ config, pkgs, ... }: { +{ config, pkgs, ... }: + +{ imports = [ - ./programs + ./programs/firefox.nix + ./programs/home-manager.nix ]; news.display = "silent"; fonts.fontconfig.enable = true; nixpkgs.config.allowUnfree = true; - programs.home-manager.enable = true; home = { - username = "freya"; - homeDirectory = "/home/freya"; - stateVersion = "25.05"; - packages = with pkgs; [ # shell starship @@ -27,13 +25,7 @@ rust-analyzer cargo clippy - # unity - unityhub - # libs - openssl - libgcc ]; - }; } diff --git a/home/nix/programs/default.nix b/home/nix/programs/default.nix deleted file mode 100644 index 1c7c3ee..0000000 --- a/home/nix/programs/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./firefox.nix - ]; -} diff --git a/home/nix/programs/firefox.nix b/home/nix/programs/firefox.nix index 61f4c17..e1ebe92 100644 --- a/home/nix/programs/firefox.nix +++ b/home/nix/programs/firefox.nix @@ -1,5 +1,7 @@ { pkgs, nixgl, ... }: let + # quick variables to specify + # locked true/false lock-false = { Value = false; Status = "locked"; @@ -8,39 +10,60 @@ Value = true; Status = "locked"; }; + + # path to nixGL binary (needed for webGL) nixGL = "${nixgl.packages.${pkgs.system}.nixGLIntel}/bin/nixGLIntel"; - my-firefox = (pkgs.firefox.override { - extraPrefs = '' - // - // Automatically click cookiebanners although uBlock Origin might block them - lockPref("cookiebanners.bannerClicking.enabled", true); - lockPref("cookiebanners.service.mode", 2); - lockPref("cookiebanners.service.mode.privateBrowsing", 2); + # modify firefox base package AND wrapper + # - set user prefs + # - fix webGL + my-firefox = (pkgs.firefox.override { # start wrapper override - // DNT although PrivacyBadger from policy handles this - lockPref("privacy.donottrackheader.enabled", true); - lockPref("privacy.donottrackheader.value", 1); + # file: mozilla.cfg + # modifies user prefs that firefox would normally not + # let me hardcode. i want to hardcode them. + extraPrefs = ''// - // New sidebar - lockPref("sidebar.revamp", true); - lockPref("sidebar.verticalTabs", true); - lockPref("sidebar.visibility", "always-show"); - lockPref("sidebar.main.tools", ""); +// Automatically click cookiebanners although uBlock Origin might block them +lockPref("cookiebanners.bannerClicking.enabled", true); +lockPref("cookiebanners.service.mode", 2); +lockPref("cookiebanners.service.mode.privateBrowsing", 2); - // - ''; - }).overrideAttrs (old: { +// DNT although PrivacyBadger from policy handles this +lockPref("privacy.donottrackheader.enabled", true); +lockPref("privacy.donottrackheader.value", 1); + +// New sidebar +lockPref("sidebar.revamp", true); +lockPref("sidebar.verticalTabs", true); +lockPref("sidebar.visibility", "always-show"); +lockPref("sidebar.main.tools", "history,bookmarks"); + +//''; + + }) # end wrapper override + .overrideAttrs (old: { # start base package override + + # modify run (build) command for firefox so that + # we can always have nixGL be called first before firefox + # ... this fixes webGL on GNU/Guix. this is likely not needed if you + # are just running nixOS buildCommand = old.buildCommand + '' sed -i "s#firefox-wrapped\"#firefox-wrapped\" \"${nixGL}\"#1" "$out/bin/firefox" ''; - }); + }); # end base package override in { programs.firefox = { + + # enable firefox and + # pass in our custom (modified) package from above enable = true; package = my-firefox; + # set firefox policies that i want + # (all that can be modified by firefox policy templates) + # see: https://mozilla.github.io/policy-templates/ policies = { EnableTrackingProtection = { Value = true; @@ -208,12 +231,19 @@ install_url = "https://addons.mozilla.org/firefox/downloads/latest/foxyproxy-standard/latest.xpi"; installation_mode = "force_installed"; }; + # Redirector + "redirector@einaregilsson.com" = { + install_url = "https://addons.mozilla.org/firefox/downloads/latest/redirector/latest.xpi"; + installation_mode = "force_installed"; + }; }; # about:config Preferences + # ... set policies that cannot be set using policies.json directly Preferences = { - # theme + # allow userChrom.css "toolkit.legacyUserProfileCustomizations.stylesheets" = lock-true; + # dark theme "extensions.activeThemeID" = { Value = "firefox-compact-dark@mozilla.org"; Status = "locked"; @@ -224,12 +254,12 @@ }; # homepage "browser.startup.homepage" = { - Value = " about:home"; + Value = "about:home"; Status = "locked"; }; "browser.newtabpage.enabed" = lock-true; "browser.newtabpage.url" = { - Value = " about:home"; + Value = "about:home"; Status = "locked"; }; # autofill @@ -270,6 +300,7 @@ "dom.webgpu.enabled" = lock-true; "media.eme.enabled" = lock-true; # user messaging + # ... disable shit that is annoying "browser.newtabpage.activity-stream.feeds.section.topstories" = lock-false; "browser.newtabpage.activity-stream.feeds.snippets" = lock-false; "browser.newtabpage.activity-stream.section.highlights.includePocket" = lock-false; @@ -313,6 +344,7 @@ }; }; + # create profile for me :3 profiles = { "freya" = { search = { @@ -326,18 +358,31 @@ "Twitter".metaData.hidden = true; }; }; + + # firefox doesnt make styling the toolbar easy using about:config + # since its just a massive json string. so i did it here in css. userChrome = '' - #sidebar-header { display:none !important; } - #sidebar-search-container { display:none !important; } - #firefox-view-button { - visibility: collapse; - } - #alltabs-button { - visibility: collapse; - } - #tabbrowser-tabs { - border-inline-start: none !important; - } +/* sidebar hack to flip contents the way i want them (arrows on the left) */ +#nav-bar-customization-target { + flex-direction: row-reverse; +} + +/* remove broken padding from sidebar hack */ +#unified-extensions-button { + padding-left: 0 !important; +} + +/* remove padding beside search bar */ +toolbarspring { + display: none !important; +} + +/* remove overflow menu and everything in it */ +#nav-bar-overflow-button, +#firefox-view-button, +#alltabs-button { + visibility: collapse; +} ''; }; }; diff --git a/home/nix/programs/home-manager.nix b/home/nix/programs/home-manager.nix new file mode 100644 index 0000000..ed16ce5 --- /dev/null +++ b/home/nix/programs/home-manager.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + programs.home-manager = { + enable = true; + }; +} diff --git a/home/nix/programs/nix-ld.nix b/home/nix/programs/nix-ld.nix new file mode 100644 index 0000000..2b5d112 --- /dev/null +++ b/home/nix/programs/nix-ld.nix @@ -0,0 +1,15 @@ +{ pkgs , ... }: + +{ + programs.nix-ld = { + # Enable Nix ld to allow precompiled executables not set for NixOS to run + enable = true; + + # Sets up all the libraries to load + libraries = with pkgs; [ + stdenv.cc.cc + zlib + openssl + ]; + }; +}