From 5a3aa36fd0eba34e8be3c72564c032c2c1cdf7ff Mon Sep 17 00:00:00 2001 From: Jan Bulthuis Date: Fri, 19 Jul 2024 21:54:41 +0200 Subject: [PATCH] Changes --- machines/laptop.nix | 1 + modules/base/default.nix | 8 ---- modules/default.nix | 1 + modules/power-saving/default.nix | 37 +++++++++++++++++ modules/users/modules/desktop/bar/waybar.nix | 2 +- modules/users/modules/desktop/default.nix | 3 ++ .../modules/desktop/window-manager/river.nix | 6 +-- modules/users/modules/firefox/default.nix | 24 +++++++++-- modules/users/modules/firefox/userChrome.css | 1 + modules/users/modules/firefox/userContent.css | 0 modules/users/modules/rofi/default.nix | 4 +- modules/users/modules/theming/default.nix | 41 +++++++++++++++---- users/jan.nix | 18 +++++++- 13 files changed, 120 insertions(+), 26 deletions(-) create mode 100644 modules/power-saving/default.nix create mode 100644 modules/users/modules/firefox/userChrome.css create mode 100644 modules/users/modules/firefox/userContent.css diff --git a/machines/laptop.nix b/machines/laptop.nix index 5819357..66af017 100644 --- a/machines/laptop.nix +++ b/machines/laptop.nix @@ -16,6 +16,7 @@ # Enabled modules modules = { base.enable = true; + power-saving.enable = false; pipewire.enable = true; wpa_supplicant.enable = true; }; diff --git a/modules/base/default.nix b/modules/base/default.nix index 1e1bc31..2aca3ae 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -36,14 +36,6 @@ in # TODO: Remove everything below, it is here out of convenience and should be elsewhere programs.dconf.enable = true; - xdg.portal = { - enable = true; - - extraPortals = with pkgs; [ - xdg-desktop-portal-gtk - xdg-desktop-portal-wlr - ]; - }; services.libinput.enable = true; modules.unfree.enable = true; modules.unfree.allowedPackages = [ diff --git a/modules/default.nix b/modules/default.nix index 379f215..24842d7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -20,6 +20,7 @@ with lib; ./greeter/greetd/tuigreet.nix ./locale/default.nix ./neovim/default.nix + ./power-saving/default.nix ./sound/pipewire.nix ./users/default.nix ./unfree/default.nix diff --git a/modules/power-saving/default.nix b/modules/power-saving/default.nix new file mode 100644 index 0000000..8fb491e --- /dev/null +++ b/modules/power-saving/default.nix @@ -0,0 +1,37 @@ +{ + lib, + config, + pkgs, + ... +}: + +with lib; +let + cfg = config.modules.power-saving; +in +{ + options.modules.power-saving = { + enable = mkEnableOption "power-saving"; + }; + + config = mkIf cfg.enable { + powerManagement.enable = true; + services.thermald.enable = true; + services.tlp = { + enable = true; + + settings = { + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 20; + }; + }; + }; +} diff --git a/modules/users/modules/desktop/bar/waybar.nix b/modules/users/modules/desktop/bar/waybar.nix index b1c2f99..289eb9d 100644 --- a/modules/users/modules/desktop/bar/waybar.nix +++ b/modules/users/modules/desktop/bar/waybar.nix @@ -110,7 +110,7 @@ in background-color: #${colors.bg}; border-style: none none solid none; border-width: ${toString theme.layout.borderSize}px; - border-color: #${colors.unfocused}; + border-color: #${colors.border-unfocused}; font-size: 12px; font-family: "${theme.fonts.monospace.name}"; } diff --git a/modules/users/modules/desktop/default.nix b/modules/users/modules/desktop/default.nix index 8e8fcef..63e6a24 100644 --- a/modules/users/modules/desktop/default.nix +++ b/modules/users/modules/desktop/default.nix @@ -27,6 +27,9 @@ in }; config = { + # Ensure desktop related systemd services (xdg) have access to session variables. + systemd.user.sessionVariables = config.home.sessionVariables; + home.packages = optionals cfg.wayland ( with pkgs; [ diff --git a/modules/users/modules/desktop/window-manager/river.nix b/modules/users/modules/desktop/window-manager/river.nix index bec6d31..4425076 100644 --- a/modules/users/modules/desktop/window-manager/river.nix +++ b/modules/users/modules/desktop/window-manager/river.nix @@ -29,7 +29,7 @@ in # Update background after rebuild home.activation = { - river = lib.hm.dag.entryAfter [ "installPackages" ] '' + river = lib.hm.dag.entryBetween [ "reloadSystemd" ] [ "installPackages" ] '' # Close waybar PATH="${pkgs.procps}/bin:$PATH" $DRY_RUN_CMD pkill waybar @@ -65,7 +65,7 @@ in 8 9 ]; - waylockOptions = "-init-color 0x${colors.bg} -input-color 0x${colors.focused} -fail-color 0x${colors.bg}"; + waylockOptions = "-init-color 0x${colors.bg} -input-color 0x${colors.border-focused} -fail-color 0x${colors.bg}"; colors = config.theming.colors; @@ -90,7 +90,7 @@ in border-width = toString config.theming.layout.borderSize; background-color = "0x${colors.bg}"; border-color-focused = "0x${colors.fg}"; - border-color-unfocused = "0x${colors.unfocused}"; # TODO: Change to use named color; + border-color-unfocused = "0x${colors.border-unfocused}"; # TODO: Change to use named color; border-color-urgent = "0x${colors.fg}"; spawn = [ diff --git a/modules/users/modules/firefox/default.nix b/modules/users/modules/firefox/default.nix index fe92a52..12aff52 100644 --- a/modules/users/modules/firefox/default.nix +++ b/modules/users/modules/firefox/default.nix @@ -5,6 +5,7 @@ ... }: +with lib; let cfg = config.modules.firefox; in @@ -25,9 +26,9 @@ in policies = { AppAutoUpdate = false; - BlockAboutAddons = true; - BlockAboutConfig = true; - BlockAboutProfiles = true; + # BlockAboutAddons = true; + # BlockAboutConfig = true; + # BlockAboutProfiles = true; DisableAppUpdate = true; DisableFeedbackCommands = true; DisableMasterPasswordCreation = true; @@ -50,11 +51,26 @@ in profiles.nixos = { search.default = "DuckDuckGo"; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ ublock-origin ]; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + # firefox-color + ublock-origin + ]; + + # Theming + userChrome = readFile ( + pkgs.substituteAll { + src = ./userChrome.css; + colors = config.theming.colorsCSS; + } + ); + # userContent = builtins.readFile ./userContent.css; settings = { "browser.tabs.inTitlebar" = 0; "extensions.autoDisableScopes" = 0; + "devtools.chrome.enabled" = true; + "devtools.debugger.remote-enabled" = true; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; }; # Force overwriting configuration file diff --git a/modules/users/modules/firefox/userChrome.css b/modules/users/modules/firefox/userChrome.css new file mode 100644 index 0000000..4df7c21 --- /dev/null +++ b/modules/users/modules/firefox/userChrome.css @@ -0,0 +1 @@ +@colors@ \ No newline at end of file diff --git a/modules/users/modules/firefox/userContent.css b/modules/users/modules/firefox/userContent.css new file mode 100644 index 0000000..e69de29 diff --git a/modules/users/modules/rofi/default.nix b/modules/users/modules/rofi/default.nix index 179bd73..c528068 100644 --- a/modules/users/modules/rofi/default.nix +++ b/modules/users/modules/rofi/default.nix @@ -34,7 +34,7 @@ in border = mkLiteral "${toString theme.layout.borderSize}px"; }; element-text = { - highlight = mkLiteral "#${colors.accent}"; + highlight = mkLiteral "#${colors.fg-search}"; }; inputbar = { children = mkLiteral "[textbox-search, entry]"; @@ -53,7 +53,7 @@ in padding = mkLiteral "0px 2px"; }; "element selected" = { - background-color = mkLiteral "#${colors.unfocused}"; + background-color = mkLiteral "#${colors.border-unfocused}"; }; }; }; diff --git a/modules/users/modules/theming/default.nix b/modules/users/modules/theming/default.nix index e496370..21b7e90 100644 --- a/modules/users/modules/theming/default.nix +++ b/modules/users/modules/theming/default.nix @@ -144,22 +144,49 @@ in type = types.str; default = colors.base05; }; - accent = mkOption { + bg-status = mkOption { type = types.str; - default = colors.base09; + default = colors.base01; }; - focused = mkOption { + fg-status = mkOption { type = types.str; - default = cfg.colors.fg; + default = colors.base04; }; - unfocused = mkOption { + bg-selection = mkOption { type = types.str; default = colors.base02; }; - alert = mkOption { + bg-highlight = mkOption { type = types.str; - default = "ffffff"; # TODO: Derive color from theme + default = colors.base03; }; + fg-search = mkOption { + type = types.str; + default = colors.base0A; + }; + accent = mkOption { + type = types.str; + default = colors.base0D; + }; + border-focused = mkOption { + type = types.str; + default = cfg.colors.fg; + }; + border-unfocused = mkOption { + type = types.str; + default = cfg.colors.bg-selection; + }; + }; + + colorsCSS = mkOption { + type = types.lines; + default = + ":root {\n" + + concatStrings ( + map (color: " --nix-color-${color.name}: #${color.value};\n") (attrsToList cfg.colors) + ) + + "}\n\n"; + description = "Colors as css variables"; }; layout = { diff --git a/users/jan.nix b/users/jan.nix index 6743c5e..037a8db 100644 --- a/users/jan.nix +++ b/users/jan.nix @@ -1,6 +1,6 @@ # How Jan likes his linux to be configured -{ config, ... }: +{ config, pkgs, ... }: { config = { @@ -29,6 +29,7 @@ discord.enable = true; qutebrowser.enable = true; neovim.enable = true; + rofi-rbw.enable = true; # Programming languages nix.enable = true; @@ -57,5 +58,20 @@ flavor = "frappe"; }; }; + + # TODO: Remove everything below, it is here out of convenience and should be elsewhere + xdg.portal = { + enable = true; + + config.common.default = [ + "wlr" + "gtk" + ]; + + extraPortals = with pkgs; [ + xdg-desktop-portal-gtk + xdg-desktop-portal-wlr + ]; + }; }; }