From 9ad52c1baafe6178f5562120e0e961e98c6c1eb6 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sun, 5 Nov 2023 20:50:08 +0800 Subject: [PATCH] home: more sorting --- .../home-manager/nixos/browser/chromium.nix | 32 +++ .../home-manager/nixos/browser/firefox.nix | 7 + .../home-manager/nixos/browser/librewolf.nix | 103 +++++++++ .../home-manager/nixos/dotfiles.nix | 4 - users/guanranwang/home-manager/nixos/home.nix | 215 +----------------- .../home-manager/nixos/presets/desktop.nix | 3 + .../home-manager/nixos/wm/default.nix | 3 + .../home-manager/nixos/wm/rofi.nix | 16 ++ .../home-manager/nixos/wm/sway.nix | 16 ++ .../home-manager/nixos/wm/swayidle.nix | 30 +++ .../home-manager/nixos/wm/udiskie.nix | 3 + 11 files changed, 219 insertions(+), 213 deletions(-) create mode 100644 users/guanranwang/home-manager/nixos/browser/chromium.nix create mode 100644 users/guanranwang/home-manager/nixos/browser/firefox.nix create mode 100644 users/guanranwang/home-manager/nixos/browser/librewolf.nix create mode 100644 users/guanranwang/home-manager/nixos/wm/rofi.nix create mode 100644 users/guanranwang/home-manager/nixos/wm/swayidle.nix create mode 100644 users/guanranwang/home-manager/nixos/wm/udiskie.nix diff --git a/users/guanranwang/home-manager/nixos/browser/chromium.nix b/users/guanranwang/home-manager/nixos/browser/chromium.nix new file mode 100644 index 0000000..ad029c3 --- /dev/null +++ b/users/guanranwang/home-manager/nixos/browser/chromium.nix @@ -0,0 +1,32 @@ +{...}: { + programs.chromium = { + enable = true; + #package = pkgs.ungoogled-chromium; + # ungoogled-chrome does not work with extensions for now + # https://github.com/nix-community/home-manager/issues/2216 + # https://github.com/nix-community/home-manager/issues/2585 + extensions = [ + {id = "cjpalhdlnbpafiamejdnhcphjbkeiagm";} # ublock origin + {id = "mnjggcdmjocbbbhaepdhchncahnbgone";} # sponsorblock + {id = "icallnadddjmdinamnolclfjanhfoafe";} # fastforward + {id = "dbepggeogbaibhgnhhndojpepiihcmeb";} # vimium + {id = "nngceckbapebfimnlniiiahkandclblb";} # bitwarden + {id = "gebbhagfogifgggkldgodflihgfeippi";} # return youtube dislike + {id = "eimadpbcbfnmbkopoojfekhnkhdbieeh";} # dark reader + {id = "njdfdhgcmkocbgbhcioffdbicglldapd";} # localcdn + {id = "hipekcciheckooncpjeljhnekcoolahp";} # tabliss + {id = "bgfofngpplpmpijncjegfdgilpgamhdk";} # modern scrollbar + {id = "ajhmfdgkijocedmfjonnpjfojldioehi";} # privacy pass + {id = "hkgfoiooedgoejojocmhlaklaeopbecg";} # picture in picture + #{id = "fnaicdffflnofjppbagibeoednhnbjhg";} # floccus bookmark sync + #{id = "jaoafjdoijdconemdmodhbfpianehlon";} # skip redirect + #{id = "dhdgffkkebhmkfjojejmpbldmpobfkfo";} # tampermonkey + #{id = "jinjaccalgkegednnccohejagnlnfdag";} # violentmonkey + #{id = "kdbmhfkmnlmbkgbabkdealhhbfhlmmon";} # steamdb + #{id = "cmeakgjggjdlcpncigglobpjbkabhmjl";} # steam inventory helper + #{id = "mgijmajocgfcbeboacabfgobmjgjcoja";} # google dictionary + #{id = "kbfnbcaeplbcioakkpcpgfkobkghlhen";} # grammarly + #{id = "ekbmhggedfdlajiikminikhcjffbleac";} # 喵喵折+ + ]; + }; +} diff --git a/users/guanranwang/home-manager/nixos/browser/firefox.nix b/users/guanranwang/home-manager/nixos/browser/firefox.nix new file mode 100644 index 0000000..596beda --- /dev/null +++ b/users/guanranwang/home-manager/nixos/browser/firefox.nix @@ -0,0 +1,7 @@ +{...}: { + programs = { + enable = true; + # TODO + profiles."default" = {}; + }; +} diff --git a/users/guanranwang/home-manager/nixos/browser/librewolf.nix b/users/guanranwang/home-manager/nixos/browser/librewolf.nix new file mode 100644 index 0000000..1ce7c4f --- /dev/null +++ b/users/guanranwang/home-manager/nixos/browser/librewolf.nix @@ -0,0 +1,103 @@ +{...}: { + programs.librewolf = { + enable = true; + settings = { + "identity.fxaccounts.enabled" = true; + + # https:#github.com/yokoffing/Betterfox/blob/main/librewolf.overrides.cfg + ### SECTION: FASTFOX + "layout.css.grid-template-masonry-value.enabled" = true; + "dom.enable_web_task_scheduling" = true; + + ### SECTION: SECUREFOX + # TRACKING PROTECTION + "urlclassifier.trackingSkipURLs" = "*.reddit.com, *.twitter.com, *.twimg.com"; + "urlclassifier.features.socialtracking.skipURLs" = "*.instagram.com, *.twitter.com, *.twimg.com"; + + ### OCSP & CERTS / HPKP + # Use CRLite instead of OCSP + "security.OCSP.enabled" = 0; + "security.OCSP.require" = false; + "security.pki.crlite_mode" = 2; + + ### RFP + # Limits refresh rate to 60mHz, breaks timezone, and forced light theme + # [1] https:#librewolf.net/docs/faq/#what-are-the-most-common-downsides-of-rfp-resist-fingerprinting + "privacy.resistFingerprinting" = false; + + ### WebGL + # Breaks Map sites, NYT articles, Nat Geo, and more + # [1] https:#manu.ninja/25-real-world-applications-using-webgl/ + "webgl.disabled" = false; + + # DRM + # Netflix, Udemy, Spotify, etc. + "media.eme.enabled" = true; + + # HTTPS-ONLY MODE + "dom.security.https_only_mode_error_page_user_suggestions" = true; + + # PASSWORDS AND AUTOFILL + "signon.generation.enabled" = false; + + ### WEBRTC + # Breaks video conferencing + "media.peerconnection.ice.no_host" = false; + + ### PERMISSIONS + "permissions.default.geo" = 2; + "permissions.default.desktop-notification" = 2; + "dom.push.enabled" = false; + + ### SECTION: PESKYFOX + ### MOZILLA UI + "layout.css.prefers-color-scheme.content-override" = 2; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "browser.compactmode.show" = true; + + ### FULLSCREEN + "full-screen-api.transition-duration.enter" = "0 0"; + "full-screen-api.transition-duration.leave" = "0 0"; + "full-screen-api.warning.delay" = 0; + "full-screen-api.warning.timeout" = 0; + + ### URL BAR + "browser.urlbar.suggest.engines" = false; + "browser.urlbar.suggest.topsites" = false; + "browser.urlbar.suggest.calculator" = true; + "browser.urlbar.unitConversion.enabled" = true; + + ### AUTOPLAY + # Default breaks some video players + "media.autoplay.blocking_policy" = 0; + + #### PASSWORDS + "editor.truncate_user_pastes" = false; + + #### DOWNLOADS + "browser.download.autohideButton" = true; + + ### PDF + "browser.download.open_pdf_attachments_inline" = true; + + ### TAB BEHAVIOR + "browser.tabs.loadBookmarksInTabs" = true; + "browser.bookmarks.openInTabClosesMenu" = false; + "findbar.highlightAll" = true; + + ### SECTION: SMOOTHFOX + "apz.overscroll.enabled" = true; + "general.smoothScroll" = true; + "general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS" = 12; + "general.smoothScroll.msdPhysics.enabled" = true; + "general.smoothScroll.msdPhysics.motionBeginSpringConstant" = 600; + "general.smoothScroll.msdPhysics.regularSpringConstant" = 650; + "general.smoothScroll.msdPhysics.slowdownMinDeltaMS" = 25; + "general.smoothScroll.msdPhysics.slowdownMinDeltaRatio" = "2.0"; + "general.smoothScroll.msdPhysics.slowdownSpringConstant" = 250; + "general.smoothScroll.currentVelocityWeighting" = "1.0"; + "general.smoothScroll.stopDecelerationWeighting" = "1.0"; + "mousewheel.default.delta_multiplier_y" = 75; + }; + }; +} diff --git a/users/guanranwang/home-manager/nixos/dotfiles.nix b/users/guanranwang/home-manager/nixos/dotfiles.nix index d21aed7..7fc958b 100644 --- a/users/guanranwang/home-manager/nixos/dotfiles.nix +++ b/users/guanranwang/home-manager/nixos/dotfiles.nix @@ -17,10 +17,6 @@ in { source = "${configPath}/picom"; recursive = true; }; - "rofi" = { - source = "${configPath}/rofi"; - recursive = true; - }; "makepkgs.conf" = { source = "${configPath}/makepkgs.conf"; diff --git a/users/guanranwang/home-manager/nixos/home.nix b/users/guanranwang/home-manager/nixos/home.nix index 2b5c603..004fb47 100644 --- a/users/guanranwang/home-manager/nixos/home.nix +++ b/users/guanranwang/home-manager/nixos/home.nix @@ -5,32 +5,6 @@ packages = (with pkgs; [ - # x11 + wayland - rofi-wayland - rofi-power-menu - pamixer - brightnessctl - playerctl - #networkmanagerapplet - pavucontrol - - # wayland - wl-clipboard - cliphist - swaylock-effects - grim - slurp - swappy - mpvpaper - libnotify - jq - - # x11 - #polybar - #picom - #feh - #flameshot - # gui gparted timeshift @@ -150,187 +124,10 @@ # }; #}; - services = { - udiskie.enable = true; - swayidle = let - lockCommand = "${pkgs.swaylock-effects}/bin/swaylock --screenshots --clock --indicator --line-color cdd6f4ff --text-color cdd6f4ff --inside-color 1e1e2eff --ring-color 313244ff --line-ver-color cdd6f4ff --text-ver-color cdd6f4ff --inside-ver-color 1e1e2eff --ring-ver-color 313244ff --line-clear-color cdd6f4ff --text-clear-color cdd6f4ff --inside-clear-color 1e1e2eff --ring-clear-color 313244ff --line-clear-color cdd6f4ff --text-wrong-color 313244ff --inside-wrong-color f38ba8ff --ring-wrong-color 313244ff --key-hl-color cba6f7ff --effect-blur 7x5 --effect-vignette 0.5:0.5 --fade-in 0.2"; - in { - enable = true; - timeouts = [ - { - timeout = 900; - command = "loginctl lock-session"; - } - { - timeout = 905; - command = ''${pkgs.sway}/bin/swaymsg "output * dpms off"''; - resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * dpms on"''; - } # turn off screen - ]; - events = [ - { - event = "lock"; - command = lockCommand; - } # loginctl lock-session - { - event = "before-sleep"; - command = lockCommand; - } # systemctl syspend - ]; - }; - }; - - programs = { - rofi = { - #enable = true; - package = pkgs.rofi-wayland; - font = "monospace"; - terminal = "${pkgs.alacritty}/bin/alacritty"; - }; - - #boxxy = { - # enable = true; - # #rules = { - # # - # #}; - #}; - - firefox = { - #enable = true; - profiles."default" = {}; - }; - - librewolf = { - enable = true; - settings = { - "identity.fxaccounts.enabled" = true; - - # https:#github.com/yokoffing/Betterfox/blob/main/librewolf.overrides.cfg - ### SECTION: FASTFOX - "layout.css.grid-template-masonry-value.enabled" = true; - "dom.enable_web_task_scheduling" = true; - - ### SECTION: SECUREFOX - # TRACKING PROTECTION - "urlclassifier.trackingSkipURLs" = "*.reddit.com, *.twitter.com, *.twimg.com"; - "urlclassifier.features.socialtracking.skipURLs" = "*.instagram.com, *.twitter.com, *.twimg.com"; - - ### OCSP & CERTS / HPKP - # Use CRLite instead of OCSP - "security.OCSP.enabled" = 0; - "security.OCSP.require" = false; - "security.pki.crlite_mode" = 2; - - ### RFP - # Limits refresh rate to 60mHz, breaks timezone, and forced light theme - # [1] https:#librewolf.net/docs/faq/#what-are-the-most-common-downsides-of-rfp-resist-fingerprinting - "privacy.resistFingerprinting" = false; - - ### WebGL - # Breaks Map sites, NYT articles, Nat Geo, and more - # [1] https:#manu.ninja/25-real-world-applications-using-webgl/ - "webgl.disabled" = false; - - # DRM - # Netflix, Udemy, Spotify, etc. - "media.eme.enabled" = true; - - # HTTPS-ONLY MODE - "dom.security.https_only_mode_error_page_user_suggestions" = true; - - # PASSWORDS AND AUTOFILL - "signon.generation.enabled" = false; - - ### WEBRTC - # Breaks video conferencing - "media.peerconnection.ice.no_host" = false; - - ### PERMISSIONS - "permissions.default.geo" = 2; - "permissions.default.desktop-notification" = 2; - "dom.push.enabled" = false; - - ### SECTION: PESKYFOX - ### MOZILLA UI - "layout.css.prefers-color-scheme.content-override" = 2; - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; - "browser.compactmode.show" = true; - - ### FULLSCREEN - "full-screen-api.transition-duration.enter" = "0 0"; - "full-screen-api.transition-duration.leave" = "0 0"; - "full-screen-api.warning.delay" = 0; - "full-screen-api.warning.timeout" = 0; - - ### URL BAR - "browser.urlbar.suggest.engines" = false; - "browser.urlbar.suggest.topsites" = false; - "browser.urlbar.suggest.calculator" = true; - "browser.urlbar.unitConversion.enabled" = true; - - ### AUTOPLAY - # Default breaks some video players - "media.autoplay.blocking_policy" = 0; - - #### PASSWORDS - "editor.truncate_user_pastes" = false; - - #### DOWNLOADS - "browser.download.autohideButton" = true; - - ### PDF - "browser.download.open_pdf_attachments_inline" = true; - - ### TAB BEHAVIOR - "browser.tabs.loadBookmarksInTabs" = true; - "browser.bookmarks.openInTabClosesMenu" = false; - "findbar.highlightAll" = true; - - ### SECTION: SMOOTHFOX - "apz.overscroll.enabled" = true; - "general.smoothScroll" = true; - "general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS" = 12; - "general.smoothScroll.msdPhysics.enabled" = true; - "general.smoothScroll.msdPhysics.motionBeginSpringConstant" = 600; - "general.smoothScroll.msdPhysics.regularSpringConstant" = 650; - "general.smoothScroll.msdPhysics.slowdownMinDeltaMS" = 25; - "general.smoothScroll.msdPhysics.slowdownMinDeltaRatio" = "2.0"; - "general.smoothScroll.msdPhysics.slowdownSpringConstant" = 250; - "general.smoothScroll.currentVelocityWeighting" = "1.0"; - "general.smoothScroll.stopDecelerationWeighting" = "1.0"; - "mousewheel.default.delta_multiplier_y" = 75; - }; - }; - - chromium = { - enable = true; - #package = pkgs.ungoogled-chromium; - # ungoogled-chrome does not work with extensions for now - # https://github.com/nix-community/home-manager/issues/2216 - # https://github.com/nix-community/home-manager/issues/2585 - extensions = [ - {id = "cjpalhdlnbpafiamejdnhcphjbkeiagm";} # ublock origin - {id = "mnjggcdmjocbbbhaepdhchncahnbgone";} # sponsorblock - {id = "icallnadddjmdinamnolclfjanhfoafe";} # fastforward - {id = "dbepggeogbaibhgnhhndojpepiihcmeb";} # vimium - {id = "nngceckbapebfimnlniiiahkandclblb";} # bitwarden - {id = "gebbhagfogifgggkldgodflihgfeippi";} # return youtube dislike - {id = "eimadpbcbfnmbkopoojfekhnkhdbieeh";} # dark reader - {id = "njdfdhgcmkocbgbhcioffdbicglldapd";} # localcdn - {id = "hipekcciheckooncpjeljhnekcoolahp";} # tabliss - {id = "bgfofngpplpmpijncjegfdgilpgamhdk";} # modern scrollbar - {id = "ajhmfdgkijocedmfjonnpjfojldioehi";} # privacy pass - {id = "hkgfoiooedgoejojocmhlaklaeopbecg";} # picture in picture - #{ id = "fnaicdffflnofjppbagibeoednhnbjhg"; } # floccus bookmark sync - #{ id = "jaoafjdoijdconemdmodhbfpianehlon"; } # skip redirect - #{ id = "dhdgffkkebhmkfjojejmpbldmpobfkfo"; } # tampermonkey - #{ id = "jinjaccalgkegednnccohejagnlnfdag"; } # violentmonkey - #{ id = "kdbmhfkmnlmbkgbabkdealhhbfhlmmon"; } # steamdb - #{ id = "cmeakgjggjdlcpncigglobpjbkabhmjl"; } # steam inventory helper - #{ id = "mgijmajocgfcbeboacabfgobmjgjcoja"; } # google dictionary - #{ id = "kbfnbcaeplbcioakkpcpgfkobkghlhen"; } # grammarly - #{ id = "ekbmhggedfdlajiikminikhcjffbleac"; } # 喵喵折+ - ]; - }; - }; + #programs.boxxy = { + # enable = true; + # #rules = { + # # + # #}; + #}; } diff --git a/users/guanranwang/home-manager/nixos/presets/desktop.nix b/users/guanranwang/home-manager/nixos/presets/desktop.nix index 832b82f..a5e5ffa 100644 --- a/users/guanranwang/home-manager/nixos/presets/desktop.nix +++ b/users/guanranwang/home-manager/nixos/presets/desktop.nix @@ -8,6 +8,9 @@ ../../resources/editor/neovim.nix ../../resources/editor/vscode.nix + ../browser/chromium.nix + ../browser/librewolf.nix + ../home.nix ../dotfiles.nix diff --git a/users/guanranwang/home-manager/nixos/wm/default.nix b/users/guanranwang/home-manager/nixos/wm/default.nix index 9a83d67..0b64904 100644 --- a/users/guanranwang/home-manager/nixos/wm/default.nix +++ b/users/guanranwang/home-manager/nixos/wm/default.nix @@ -1,7 +1,10 @@ {...}: { imports = [ ./dunst.nix + ./rofi.nix ./sway.nix + ./swayidle.nix + ./udiskie.nix ./waybar.nix ]; } diff --git a/users/guanranwang/home-manager/nixos/wm/rofi.nix b/users/guanranwang/home-manager/nixos/wm/rofi.nix new file mode 100644 index 0000000..7e92289 --- /dev/null +++ b/users/guanranwang/home-manager/nixos/wm/rofi.nix @@ -0,0 +1,16 @@ +{pkgs, ...}: { + programs.rofi = { + enable = true; + package = pkgs.rofi-wayland; + font = "monospace"; + terminal = "${pkgs.alacritty}/bin/alacritty"; + }; + + home.packages = with pkgs; [rofi-power-menu]; + + # Yes, because I have no idea how to use programs.rofi.theme + xdg.configFile."rofi" = { + source = ../../resources/dotfiles/config/rofi; + recursive = true; + }; +} diff --git a/users/guanranwang/home-manager/nixos/wm/sway.nix b/users/guanranwang/home-manager/nixos/wm/sway.nix index 1afe679..fca01da 100644 --- a/users/guanranwang/home-manager/nixos/wm/sway.nix +++ b/users/guanranwang/home-manager/nixos/wm/sway.nix @@ -15,6 +15,22 @@ GTK_IM_MODULE = lib.mkForce ""; # use text-input-v3 }; + home.packages = with pkgs; [ + pamixer + brightnessctl + playerctl + pavucontrol + wl-clipboard + cliphist + swaylock-effects + grim + slurp + swappy + #mpvpaper + libnotify + jq + ]; + wayland.windowManager.sway = { enable = true; extraOptions = ["--unsupported-gpu" "-D" "noscanout"]; diff --git a/users/guanranwang/home-manager/nixos/wm/swayidle.nix b/users/guanranwang/home-manager/nixos/wm/swayidle.nix new file mode 100644 index 0000000..cee75dd --- /dev/null +++ b/users/guanranwang/home-manager/nixos/wm/swayidle.nix @@ -0,0 +1,30 @@ +{pkgs, ...}: { + services = { + swayidle = let + lockCommand = "${pkgs.swaylock-effects}/bin/swaylock --screenshots --clock --indicator --line-color cdd6f4ff --text-color cdd6f4ff --inside-color 1e1e2eff --ring-color 313244ff --line-ver-color cdd6f4ff --text-ver-color cdd6f4ff --inside-ver-color 1e1e2eff --ring-ver-color 313244ff --line-clear-color cdd6f4ff --text-clear-color cdd6f4ff --inside-clear-color 1e1e2eff --ring-clear-color 313244ff --line-clear-color cdd6f4ff --text-wrong-color 313244ff --inside-wrong-color f38ba8ff --ring-wrong-color 313244ff --key-hl-color cba6f7ff --effect-blur 7x5 --effect-vignette 0.5:0.5 --fade-in 0.2"; + in { + enable = true; + timeouts = [ + { + timeout = 900; + command = "loginctl lock-session"; + } + { + timeout = 905; + command = ''${pkgs.sway}/bin/swaymsg "output * dpms off"''; + resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * dpms on"''; + } # turn off screen + ]; + events = [ + { + event = "lock"; + command = lockCommand; + } # loginctl lock-session + { + event = "before-sleep"; + command = lockCommand; + } # systemctl syspend + ]; + }; + }; +} diff --git a/users/guanranwang/home-manager/nixos/wm/udiskie.nix b/users/guanranwang/home-manager/nixos/wm/udiskie.nix new file mode 100644 index 0000000..81fc5df --- /dev/null +++ b/users/guanranwang/home-manager/nixos/wm/udiskie.nix @@ -0,0 +1,3 @@ +{...}: { + services.udiskie.enable = true; +}