From 71eb43c7b2999b323453e74196d9171d238e7da6 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 28 Sep 2023 21:05:29 +0100 Subject: [PATCH] home-manager/desktop: convert it to module --- home-manager/chromium.nix | 14 ------ home-manager/default.nix | 2 +- home-manager/desktop.nix | 75 ----------------------------- home-manager/desktop/chromium.nix | 20 ++++++++ home-manager/desktop/default.nix | 79 +++++++++++++++++++++++++++++++ home-manager/desktop/firefox.nix | 42 ++++++++++++++++ home-manager/firefox.nix | 36 -------------- 7 files changed, 142 insertions(+), 126 deletions(-) delete mode 100644 home-manager/chromium.nix delete mode 100644 home-manager/desktop.nix create mode 100644 home-manager/desktop/chromium.nix create mode 100644 home-manager/desktop/default.nix create mode 100644 home-manager/desktop/firefox.nix delete mode 100644 home-manager/firefox.nix diff --git a/home-manager/chromium.nix b/home-manager/chromium.nix deleted file mode 100644 index 87910714..00000000 --- a/home-manager/chromium.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ pkgs, ... }: - -{ - programs.chromium = { - enable = true; - package = pkgs.chromium.override { - enableWideVine = true; - }; - extensions = [ - { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin - { id = "hfjbmagddngcpeloejdejnfgbamkjaeg"; } # vimium-c - ]; - }; -} diff --git a/home-manager/default.nix b/home-manager/default.nix index bb3afcd5..e877bf9a 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -3,7 +3,7 @@ { imports = [ ./cli - ./desktop.nix + ./desktop ./emacs ./i3 ./kitty.nix diff --git a/home-manager/desktop.nix b/home-manager/desktop.nix deleted file mode 100644 index e5fac0cc..00000000 --- a/home-manager/desktop.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ pkgs, ... }: - -{ - imports = [ - ./chromium.nix - ./firefox.nix - ]; - - home.packages = with pkgs; [ - android-file-transfer - audacious - (calibre.override { unrarSupport = true; }) - (cinnamon.nemo-with-extensions.override { extensions = with cinnamon; [ nemo-fileroller ]; }) - desktop-file-utils - ffmpeg - gammastep - gimp - gnome.evince - gnome.file-roller - gnome.gnome-disk-utility - gthumb - inkscape - libreoffice-fresh - open-browser - (mcomix.override { unrarSupport = true; }) - pavucontrol - pinta - qalculate-gtk - vlc - xclip - xdotool - xdragon - xorg.xdpyinfo - xorg.xhost - xorg.xkill - xorg.xset - zoom-us - ]; - - services = { - easyeffects.enable = true; - udiskie = { - enable = true; - tray = "always"; - }; - }; - - xdg = { - # Some applications like to overwrite this file, so let's just force it - configFile."mimeapps.list".force = true; - - mimeApps = { - enable = true; - defaultApplications = { - "application/pdf" = "org.gnome.Evince.desktop"; - "image/gif" = "org.gnome.gThumb.desktop"; - "image/jpeg" = "org.gnome.gThumb.desktop"; - "image/png" = "org.gnome.gThumb.desktop"; - "inode/directory" = "nemo.desktop"; - "text/html" = "open-browser.desktop"; - "text/plain" = "emacs.desktop"; - "text/x-makefile" = "emacs.desktop"; - "x-scheme-handler/about" = "open-browser.desktop"; - "x-scheme-handler/http" = "open-browser.desktop"; - "x-scheme-handler/https" = "open-browser.desktop"; - "x-scheme-handler/unknown" = "open-browser.desktop"; - }; - }; - - userDirs = { - enable = true; - createDirectories = true; - }; - }; -} diff --git a/home-manager/desktop/chromium.nix b/home-manager/desktop/chromium.nix new file mode 100644 index 00000000..0040d90f --- /dev/null +++ b/home-manager/desktop/chromium.nix @@ -0,0 +1,20 @@ +{ config, pkgs, lib, ... }: + +{ + options.home-manager.desktop.chromium.enable = lib.mkEnableOption "Chromium config" // { + default = config.home-manager.desktop.enable; + }; + + config = lib.mkIf config.home-manager.desktop.chromium.enable { + programs.chromium = { + enable = true; + package = pkgs.chromium.override { + enableWideVine = true; + }; + extensions = [ + { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin + { id = "hfjbmagddngcpeloejdejnfgbamkjaeg"; } # vimium-c + ]; + }; + }; +} diff --git a/home-manager/desktop/default.nix b/home-manager/desktop/default.nix new file mode 100644 index 00000000..6b1281a8 --- /dev/null +++ b/home-manager/desktop/default.nix @@ -0,0 +1,79 @@ +{ config, pkgs, lib, ... }: + +{ + imports = [ + ./chromium.nix + ./firefox.nix + ]; + + options.home-manager.desktop.enable = lib.mkDefaultOption "desktop config"; + + config = lib.mkIf config.home-manager.desktop.enable { + home.packages = with pkgs; [ + android-file-transfer + audacious + (calibre.override { unrarSupport = true; }) + (cinnamon.nemo-with-extensions.override { extensions = with cinnamon; [ nemo-fileroller ]; }) + desktop-file-utils + ffmpeg + gammastep + gimp + gnome.evince + gnome.file-roller + gnome.gnome-disk-utility + gthumb + inkscape + libreoffice-fresh + open-browser + (mcomix.override { unrarSupport = true; }) + pavucontrol + pinta + qalculate-gtk + vlc + xclip + xdotool + xdragon + xorg.xdpyinfo + xorg.xhost + xorg.xkill + xorg.xset + zoom-us + ]; + + services = { + easyeffects.enable = true; + udiskie = { + enable = true; + tray = "always"; + }; + }; + + xdg = { + # Some applications like to overwrite this file, so let's just force it + configFile."mimeapps.list".force = true; + + mimeApps = { + enable = true; + defaultApplications = { + "application/pdf" = "org.gnome.Evince.desktop"; + "image/gif" = "org.gnome.gThumb.desktop"; + "image/jpeg" = "org.gnome.gThumb.desktop"; + "image/png" = "org.gnome.gThumb.desktop"; + "inode/directory" = "nemo.desktop"; + "text/html" = "open-browser.desktop"; + "text/plain" = "emacs.desktop"; + "text/x-makefile" = "emacs.desktop"; + "x-scheme-handler/about" = "open-browser.desktop"; + "x-scheme-handler/http" = "open-browser.desktop"; + "x-scheme-handler/https" = "open-browser.desktop"; + "x-scheme-handler/unknown" = "open-browser.desktop"; + }; + }; + + userDirs = { + enable = true; + createDirectories = true; + }; + }; + }; +} diff --git a/home-manager/desktop/firefox.nix b/home-manager/desktop/firefox.nix new file mode 100644 index 00000000..7c2a2d82 --- /dev/null +++ b/home-manager/desktop/firefox.nix @@ -0,0 +1,42 @@ +{ config, lib, osConfig, ... }: + +let + inherit (config.home) username; + subpixelRender = (osConfig.fonts.fontconfig.antialias or false) && + (osConfig.fonts.fontconfig.subpixel.rgba != "none"); +in +{ + options.home-manager.desktop.firefox.enable = lib.mkEnableOption "Firefox config" // { + default = config.home-manager.desktop.enable; + }; + + config = lib.mkIf config.home-manager.desktop.firefox.enable { + programs.firefox = { + enable = true; + profiles.${username} = { + settings = { + # disable annoyinh Ctrl+Q shortcut + "browser.quitShortcut.disabled" = true; + # enable hw video acceleration, if supported + "media.ffmpeg.vaapi.enabled" = true; + # handpicked settings from: https://github.com/arkenfox/user.js/blob/master/user.js + # ads + "browser.newtabpage.activity-stream.showSponsored" = false; + "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; + "extensions.htmlaboutaddons.recommendations.enabled" = false; + "browser.urlbar.suggest.quicksuggest.sponsored" = false; + # telemetry + "datareporting.policy.dataSubmissionEnable" = false; + "datareporting.healthreport.uploadEnabled" = false; + "app.shield.optoutstudies.enabled" = false; + "app.normandy.enabled" = false; + "browser.tabs.crashReporting.sendReport" = false; + } // lib.optionalAttrs subpixelRender { + # https://pandasauce.org/get-fonts-done/ + "gfx.text.subpixel-position.force-enabled" = true; + "gfx.webrender.quality.force-subpixel-aa-where-possible" = true; + }; + }; + }; + }; +} diff --git a/home-manager/firefox.nix b/home-manager/firefox.nix deleted file mode 100644 index 18099864..00000000 --- a/home-manager/firefox.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ config, lib, osConfig, ... }: - -let - inherit (config.home) username; - subpixelRender = (osConfig.fonts.fontconfig.antialias or false) && - (osConfig.fonts.fontconfig.subpixel.rgba != "none"); -in -{ - programs.firefox = { - enable = true; - profiles.${username} = { - settings = { - # disable annoyinh Ctrl+Q shortcut - "browser.quitShortcut.disabled" = true; - # enable hw video acceleration, if supported - "media.ffmpeg.vaapi.enabled" = true; - # handpicked settings from: https://github.com/arkenfox/user.js/blob/master/user.js - # ads - "browser.newtabpage.activity-stream.showSponsored" = false; - "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; - "extensions.htmlaboutaddons.recommendations.enabled" = false; - "browser.urlbar.suggest.quicksuggest.sponsored" = false; - # telemetry - "datareporting.policy.dataSubmissionEnable" = false; - "datareporting.healthreport.uploadEnabled" = false; - "app.shield.optoutstudies.enabled" = false; - "app.normandy.enabled" = false; - "browser.tabs.crashReporting.sendReport" = false; - } // lib.optionalAttrs subpixelRender { - # https://pandasauce.org/get-fonts-done/ - "gfx.text.subpixel-position.force-enabled" = true; - "gfx.webrender.quality.force-subpixel-aa-where-possible" = true; - }; - }; - }; -}