Further progress, improved dark mode handling

This commit is contained in:
Jan Bulthuis 2024-07-19 01:00:39 +02:00
parent 36c9c7a90d
commit 23c2ef87b0
7 changed files with 295 additions and 163 deletions

View File

@ -11,6 +11,8 @@
./foot/default.nix ./foot/default.nix
./mako/default.nix ./mako/default.nix
./obsidian/default.nix ./obsidian/default.nix
./rofi/default.nix
./rofi/rofi-rbw.nix
./shell/bash.nix ./shell/bash.nix
./shell/fish.nix ./shell/fish.nix
./steam/default.nix ./steam/default.nix

View File

@ -11,6 +11,7 @@ in {
]; ];
options.modules.desktop = { options.modules.desktop = {
wayland = mkEnableOption "wayland";
initScript = mkOption { initScript = mkOption {
type = types.lines; type = types.lines;
default = "${pkgs.bash}/bin/bash"; default = "${pkgs.bash}/bin/bash";
@ -19,6 +20,11 @@ in {
}; };
config = { config = {
home.packages = optionals cfg.wayland (with pkgs; [
pkgs.wl-clipboard
pkgs.wtype
]);
home.file.".initrc" = { home.file.".initrc" = {
enable = true; enable = true;
executable = true; executable = true;

View File

@ -10,6 +10,9 @@ in {
# }; # };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# Set desktop type to wayland
modules.desktop.wayland = true;
# Change desktop to execute river # Change desktop to execute river
modules.desktop.initScript = '' modules.desktop.initScript = ''
river river

View File

@ -0,0 +1,53 @@
{config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.rofi;
theme = config.theming;
colors = theme.colors;
in {
options.modules.rofi.enable = mkEnableOption "rofi";
config = mkIf cfg.enable {
programs.rofi = {
enable = true;
package = pkgs.rofi-wayland;
font = "${theme.fonts.monospace.name} ${toString theme.fonts.monospace.recommendedSize}";
theme = let
inherit (config.lib.formats.rasi) mkLiteral;
in {
"*" = {
background-color = mkLiteral "rgba(0, 0, 0, 0%)";
border-color = mkLiteral "#${colors.fg}";
text-color = mkLiteral "#${colors.fg}";
};
mainbox = {
background-color = mkLiteral "#${colors.bg}";
border = mkLiteral "${toString theme.layout.borderSize}px";
};
element-text = {
highlight = mkLiteral "#${colors.accent}";
};
inputbar = {
children = mkLiteral "[textbox-search, entry]";
};
listview = {
padding = mkLiteral "2px 0px";
};
textbox-search = {
expand = false;
content = "> ";
};
"inputbar, message" = {
padding = mkLiteral "2px";
};
element = {
padding = mkLiteral "0px 2px";
};
"element selected" = {
background-color = mkLiteral "#${colors.focused}";
};
};
};
};
}

View File

@ -0,0 +1,27 @@
{config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.rofi-rbw;
in {
options.modules.rofi-rbw.enable = mkEnableOption "rofi-rbw";
config = mkIf cfg.enable {
modules.rofi.enable = true;
home.packages = [
pkgs.rofi-rbw
];
# TODO: Move to separate module and make configurable
programs.rbw = {
enable = true;
settings = {
base_url = "https://keys.bulthuis.dev";
identity_url = "https://keys.bulthuis.dev";
email = "jan@bulthuis.dev";
pinentry = pkgs.pinentry;
};
};
};
}

View File

@ -104,6 +104,12 @@ in {
description = "Base 16 color scheme to use for styling. See stylix documentation for more information."; description = "Base 16 color scheme to use for styling. See stylix documentation for more information.";
}; };
clientSideDecorations = mkOption {
type = types.bool;
default = false;
description = "Whether to enable client side decorations for windows.";
};
schemeColors = mkOption { schemeColors = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
default = config.lib.stylix.colors; default = config.lib.stylix.colors;
@ -208,6 +214,45 @@ in {
# Install configured fonts # Install configured fonts
home.packages = fontPackageList; home.packages = fontPackageList;
# Configure gnome theme
dconf.settings = {
"org/gnome/desktop/interface" = {
color-scheme = if cfg.darkMode then "prefer-dark" else "prefer-light";
};
};
# Configure qt theme
qt = {
enable = true;
platformTheme.name = "adwaita";
style.name = if cfg.darkMode then "adwaita-dark" else "adwaita-light";
};
# Configure gtk theme
gtk = let
disableCSD = ''
headerbar.default-decoration {
margin-bottom: 50px;
margin-top: -100px;
}
window.csd,
window.csd decoration {
box-shadow: none;
}
'';
in {
enable = true;
theme = {
name = if cfg.darkMode then "Adwaita-dark" else "Adwaita-light";
package = pkgs.gnome-themes-extra;
};
gtk3.extraCss = mkIf !cfg.clientSideDecorations disableCSD;
gtk4.extraCss = mkIf !cfg.clientSideDecorations disableCSD;
}
# Enable stylix # Enable stylix
# TODO: Move to own module # TODO: Move to own module
stylix = { stylix = {

View File

@ -26,29 +26,25 @@ in {
# Utilities # Utilities
pulsemixer pulsemixer
wl-clipboard
pinentry-rofi
wtype
# waylock # waylock
playerctl playerctl
nix-tree
# Fish plugin dependencies # Fish plugin dependencies
# grc # grc
# fzf # fzf
# Rust development # Rust development
rustc # rustc
cargo # cargo
rustfmt # rustfmt
# Bitwarden # Bitwarden
rofi-rbw # rofi-rbw
# LaTeX libraries # LaTeX libraries
(pkgs.texlive.combine { # (pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-full; # inherit (pkgs.texlive) scheme-full;
}) # })
]; ];
# Stylix # Stylix
@ -57,25 +53,25 @@ in {
# polarity = "dark"; # polarity = "dark";
# base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; # base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";
fonts = { # fonts = {
# monospace = { # # monospace = {
# package = pkgs.dina-font; # # package = pkgs.dina-font;
# name = "Dina"; # # name = "Dina";
# }; # # };
sizes = { # sizes = {
terminal = 9; # terminal = 9;
}; # };
}; # };
# autoEnable = false; # autoEnable = false;
targets = { # targets = {
foot.enable = true; # foot.enable = true;
nixvim.enable = true; # nixvim.enable = true;
qutebrowser.enable = true; # qutebrowser.enable = true;
vscode.enable = true; # vscode.enable = true;
# zathura.enable = true; # # zathura.enable = true;
}; # };
}; };
# Fish shell # Fish shell
@ -136,128 +132,128 @@ in {
}; };
# Bitwarden client # Bitwarden client
programs.rbw = { # programs.rbw = {
enable = true; # enable = true;
settings = { # settings = {
base_url = "https://keys.bulthuis.dev"; # base_url = "https://keys.bulthuis.dev";
identity_url = "https://keys.bulthuis.dev"; # identity_url = "https://keys.bulthuis.dev";
email = "jan@bulthuis.dev"; # email = "jan@bulthuis.dev";
pinentry = pkgs.pinentry; # pinentry = pkgs.pinentry;
}; # };
}; # };
# Firefox # Firefox
programs.firefox = { # programs.firefox = {
enable = true; # enable = true;
policies = { # policies = {
AppAutoUpdate = false; # AppAutoUpdate = false;
BlockAboutAddons = true; # BlockAboutAddons = true;
BlockAboutConfig = true; # BlockAboutConfig = true;
BlockAboutProfiles = true; # BlockAboutProfiles = true;
DisableAppUpdate = true; # DisableAppUpdate = true;
DisableFeedbackCommands = true; # DisableFeedbackCommands = true;
DisableMasterPasswordCreation = true; # DisableMasterPasswordCreation = true;
DisablePocket = true; # DisablePocket = true;
DisableProfileImport = true; # DisableProfileImport = true;
DisableProfileRefresh = true; # DisableProfileRefresh = true;
DisableSetDesktopBackground = true; # DisableSetDesktopBackground = true;
DisableTelemetry = true; # DisableTelemetry = true;
DisplayBookmarksToolbar = "never"; # DisplayBookmarksToolbar = "never";
DisplayMenuBar = "never"; # DisplayMenuBar = "never";
DNSOverHTTPS = { Enabled = false; }; # DNSOverHTTPS = { Enabled = false; };
DontCheckDefaultBrowser = true; # DontCheckDefaultBrowser = true;
PasswordManagerEnabled = false; # PasswordManagerEnabled = false;
TranslateEnabled = true; # TranslateEnabled = true;
UseSystemPrintDialog = true; # UseSystemPrintDialog = true;
}; # };
profiles.nixos = { # profiles.nixos = {
search.default = "DuckDuckGo"; # search.default = "DuckDuckGo";
extensions = with pkgs.nur.repos.rycee.firefox-addons; [ # extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin # ublock-origin
]; # ];
settings = { # settings = {
"browser.tabs.inTitlebar" = 0; # "browser.tabs.inTitlebar" = 0;
"extensions.autoDisableScopes" = 0; # "extensions.autoDisableScopes" = 0;
}; # };
# Force overwriting configuration file # # Force overwriting configuration file
search.force = true; # search.force = true;
containersForce = true; # containersForce = true;
}; # };
}; # };
# Email setup # # Email setup
accounts.email.accounts = { # accounts.email.accounts = {
Personal = { # Personal = {
primary = true; # primary = true;
realName = "Jan Bulthuis"; # realName = "Jan Bulthuis";
userName = "jan@bulthuis.dev"; # userName = "jan@bulthuis.dev";
address = "jan@bulthuis.dev"; # address = "jan@bulthuis.dev";
thunderbird.enable = true; # thunderbird.enable = true;
flavor = "plain"; # flavor = "plain";
imap = { # imap = {
host = "mail.bulthuis.dev"; # host = "mail.bulthuis.dev";
port = 993; # port = 993;
}; # };
smtp = { # smtp = {
host = "mail.bulthuis.dev"; # host = "mail.bulthuis.dev";
port = 465; # port = 465;
}; # };
}; # };
}; # };
# Thunderbird setup # # Thunderbird setup
programs.thunderbird = { # programs.thunderbird = {
enable = true; # enable = true;
profiles.nixos = { # profiles.nixos = {
isDefault = true; # isDefault = true;
}; # };
}; # };
# Rofi setup # Rofi setup
programs.rofi = { # programs.rofi = {
enable = true; # enable = true;
package = pkgs.rofi-wayland; # package = pkgs.rofi-wayland;
font = "${fonts.monospace.name} ${toString fonts.sizes.terminal}"; # font = "${fonts.monospace.name} ${toString fonts.sizes.terminal}";
theme = let # theme = let
inherit (config.lib.formats.rasi) mkLiteral; # inherit (config.lib.formats.rasi) mkLiteral;
in { # in {
"*" = { # "*" = {
background-color = mkLiteral "rgba(0, 0, 0, 0%)"; # background-color = mkLiteral "rgba(0, 0, 0, 0%)";
border-color = mkLiteral colors.withHashtag.base05; # border-color = mkLiteral colors.withHashtag.base05;
text-color = mkLiteral colors.withHashtag.base05; # text-color = mkLiteral colors.withHashtag.base05;
}; # };
mainbox = { # mainbox = {
background-color = mkLiteral colors.withHashtag.base00; # background-color = mkLiteral colors.withHashtag.base00;
border = mkLiteral "${toString borderSize}px"; # border = mkLiteral "${toString borderSize}px";
}; # };
element-text = { # element-text = {
highlight = mkLiteral colors.withHashtag.base09; # highlight = mkLiteral colors.withHashtag.base09;
}; # };
inputbar = { # inputbar = {
children = mkLiteral "[textbox-search, entry]"; # children = mkLiteral "[textbox-search, entry]";
}; # };
listview = { # listview = {
padding = mkLiteral "2px 0px"; # padding = mkLiteral "2px 0px";
}; # };
textbox-search = { # textbox-search = {
expand = false; # expand = false;
content = "> "; # content = "> ";
}; # };
"inputbar, message" = { # "inputbar, message" = {
padding = mkLiteral "2px"; # padding = mkLiteral "2px";
}; # };
element = { # element = {
padding = mkLiteral "0px 2px"; # padding = mkLiteral "0px 2px";
}; # };
"element selected" = { # "element selected" = {
background-color = mkLiteral colors.withHashtag.base02; # background-color = mkLiteral colors.withHashtag.base02;
}; # };
}; # };
}; # };
# Dark mode # Dark mode
dconf.settings = { dconf.settings = {
@ -270,34 +266,34 @@ in {
platformTheme.name = "adwaita"; platformTheme.name = "adwaita";
style.name = "adwaita-dark"; style.name = "adwaita-dark";
}; };
systemd.user.sessionVariables = config.home.sessionVariables; # systemd.user.sessionVariables = config.home.sessionVariables;
# Configure GTK # Configure GTK
gtk = let # gtk = let
css = '' # css = ''
headerbar.default-decoration { # headerbar.default-decoration {
margin-bottom: 50px; # margin-bottom: 50px;
margin-top: -100px; # margin-top: -100px;
} # }
window.csd, # window.csd,
window.csd decoration { # window.csd decoration {
box-shadow: none; # box-shadow: none;
} # }
''; # '';
in { # in {
enable = true; # enable = true;
# Dark mode # # Dark mode
theme = { # theme = {
name = "Adwaita-dark"; # name = "Adwaita-dark";
package = pkgs.gnome-themes-extra; # package = pkgs.gnome-themes-extra;
}; # };
# Disable CSD # # Disable CSD
gtk3.extraCss = css; # gtk3.extraCss = css;
gtk4.extraCss = css; # gtk4.extraCss = css;
}; # };
# Cursors # Cursors
home.pointerCursor = { home.pointerCursor = {
@ -647,5 +643,5 @@ in {
''; '';
}; };
home.stateVersion = "24.05"; # home.stateVersion = "24.05";
} }