1

Home: Update HM module template + apply changes to modules

This commit is contained in:
2024-10-14 15:22:09 +02:00
parent 661bdeaf79
commit 620f970a8d
11 changed files with 68 additions and 94 deletions

View File

@ -5,12 +5,10 @@
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.TEMPLATE;
}: let
inherit (config.modules) TEMPLATE;
in {
options.modules.TEMPLATE = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {};
config = lib.mkIf TEMPLATE.enable {};
}

View File

@ -4,14 +4,12 @@
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.ags;
}: let
inherit (config.modules) ags;
in {
options.modules.ags = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf ags.enable {
programs.ags = {
enable = true;
systemd.enable = true;

View File

@ -1,19 +1,15 @@
# TODO: Expose some settings
{
config,
nixosConfig,
lib,
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.chromium;
}: let
inherit (config.modules) chromium;
in {
options.modules.chromium = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf chromium.enable {
home.packages = with pkgs;
builtins.concatLists [
(optionals cfg.google [

View File

@ -6,14 +6,12 @@
pkgs,
hostname,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.firefox;
}: let
inherit (config.modules) firefox;
in {
options.modules.firefox = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf firefox.enable {
home.packages = with pkgs;
builtins.concatLists [
# TODO: I don't think vaapi works yet
@ -27,18 +25,18 @@ in {
# (optionals cfg.gnomeTheme [firefox-gnome-theme])
];
home.sessionVariables = mkMerge [
home.sessionVariables = lib.mkMerge [
{
MOZ_USE_XINPUT2 = 1;
}
(optionalAttrs cfg.wayland {
(lib.optionalAttrs firefox.wayland {
MOZ_ENABLE_WAYLAND = 1;
EGL_PLATFORM = "wayland";
# XDG_CURRENT_DESKTOP = "Hyprland"; # TODO: Or "sway"? # Already set by hyprland
})
(optionalAttrs cfg.vaapi {
(lib.optionalAttrs firefox.vaapi {
# LIBVA_DRIVER_NAME = "radeonsi"; # "nvidia" for Nvidia card
# LIBVA_DRIVER_NAME = "nvidia"; # Specified in hardware-configuration
MOZ_DISABLE_RDD_SANDBOX = 1;
@ -72,7 +70,7 @@ in {
# not strictly necessary
extraPolicies = {
# TODO: Make library function to allow easy bookmark creation and add my default bookmarks/folders
Bookmarks = optionalAttrs cfg.defaultBookmarks {};
Bookmarks = lib.optionalAttrs firefox.defaultBookmarks {};
CaptivePortal = false;
DisableFirefoxAccounts = true;
DisableFirefoxStudies = true;
@ -98,13 +96,13 @@ in {
default = {
id = 0; # 0 is default profile
userChrome = concatStringsSep "\n" [
userChrome = lib.concatStringsSep "\n" [
# TODO: Borked after standalone HM
# (optionalString cfg.gnomeTheme ''
# @import "${pkgs.firefox-gnome-theme}/share/firefox-gnome-theme/gnome-theme.css";
# '')
(optionalString cfg.disableTabBar ''
(lib.optionalString firefox.disableTabBar ''
#TabsToolbar { display: none; }
'')
];
@ -153,8 +151,8 @@ in {
youtube-shorts-block
];
settings = mkMerge [
(optionalAttrs cfg.vaapi {
settings = lib.mkMerge [
(lib.optionalAttrs firefox.vaapi {
# Firefox wayland hardware video acceleration
# https://github.com/elFarto/nvidia-vaapi-driver/#firefox=
# TODO: Disable and check if it works by default
@ -255,7 +253,6 @@ in {
"identity.fxaccounts.account.device.name" = hostname;
"media.hardwaremediakeys.enabled" = false; # Do not interfere with spotify
"media.videocontrols.picture-in-picture.video-toggle.enabled" = true;
@ -278,7 +275,7 @@ in {
"toolkit.coverage.opt-out" = true;
"toolkit.coverage.endpoint.base" = "";
"toolkit.legacyUserProfileCustomizations.stylesheets" = cfg.gnomeTheme || cfg.disableTabBar;
"toolkit.legacyUserProfileCustomizations.stylesheets" = firefox.gnomeTheme || firefox.disableTabBar;
"toolkit.telemetry.unified" = false;
"toolkit.telemetry.enabled" = false;
"toolkit.telemetry.server" = "data:,";

View File

@ -4,14 +4,12 @@
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.fish;
}: let
inherit (config.modules) fish;
in {
options.modules.fish = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf fish.enable {
home.file.".config/fish/themes/catppuccin-latte.theme".text = ''
# name: 'Catppuccin Latte'
# url: 'https://github.com/catppuccin/fish'
@ -109,19 +107,19 @@ in {
shellAbbrs = let
# Only add " | bat" if bat is installed
batify = command: command + (optionalString config.programs.bat.enable " | bat");
batify = command: command + (lib.optionalString config.programs.bat.enable " | bat");
# Same as above but with args for bat
batifyWithArgs = command: args: command + (optionalString config.programs.bat.enable (" | bat " + args));
batifyWithArgs = command: args: command + (lib.optionalString config.programs.bat.enable (" | bat " + args));
# These can be used for my config.modules and for HM config.programs,
# as both of these add the package to home.packages
hasHomePackage = package: (contains config.home.packages package);
hasHomePackage = package: (mylib.contains config.home.packages package);
# Only add fish abbr if package is installed
abbrify = package: abbr: (optionalAttrs (hasHomePackage package) abbr);
abbrify = package: abbr: (lib.optionalAttrs (hasHomePackage package) abbr);
in
mkMerge [
lib.mkMerge [
# Abbrs that are always available are defined here.
{
# Shell basics

View File

@ -10,8 +10,7 @@
nixosConfig,
...
}: let
cfg = config.modules.hyprland;
color = config.modules.color;
inherit (config.modules) hyprland color;
# This function is mapped to the "cfg.monitors" attrSet.
# For each key-value entry in "cfg.monitors",
@ -29,22 +28,22 @@
+ (lib.optionalString (builtins.hasAttr "class" attrs) ", class:^(${attrs.class})$")
+ (lib.optionalString (builtins.hasAttr "title" attrs) ", title:^(${attrs.title})$");
mkTranslucentRule = class: "opacity ${cfg.transparent-opacity} ${cfg.transparent-opacity}, class:^(${class})$";
mkTranslucentRule = class: "opacity ${hyprland.transparent-opacity} ${hyprland.transparent-opacity}, class:^(${class})$";
mkBind = key: action: "${key}, ${action}";
mkBinds = key: actions: builtins.map (mkBind key) actions;
# These functions are used to generate the keybindings.info file for Rofi
fixupNoMod = key: ''${builtins.replaceStrings ["<-"] ["<"] key}'';
mkBindHelpKey = key: ''${builtins.replaceStrings ["$mainMod" " " ","] ["${cfg.keybindings.main-mod}" "-" ""] key}'';
mkBindHelpKey = key: ''${builtins.replaceStrings ["$mainMod" " " ","] ["${hyprland.keybindings.main-mod}" "-" ""] key}'';
mkBindHelpAction = action: ''${builtins.replaceStrings [","] [""] action}'';
mkBindHelp = key: action: "<${mkBindHelpKey key}>: ${mkBindHelpAction action}";
mkBindsHelp = key: actions: builtins.map fixupNoMod (builtins.map (mkBindHelp key) actions);
mkWallpaper = monitor: "${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${cfg.theme}.png";
mkWallpaper = monitor: "${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${hyprland.theme}.png";
mkDelayedStart = str: "hyprctl dispatch exec \"sleep 5s && ${str}\"";
delayed-exec = builtins.map mkDelayedStart cfg.autostart.delayed;
delayed-exec = builtins.map mkDelayedStart hyprland.autostart.delayed;
mkExec = prog: "${prog}";
always-bind = {
@ -126,7 +125,7 @@
in {
options.modules.hyprland = import ./options.nix {inherit lib mylib;};
config = lib.mkIf cfg.enable {
config = lib.mkIf hyprland.enable {
# Some assertion is not possible if HM is used standalone,
# because nixosConfig won't be available.
assertions = [
@ -174,7 +173,7 @@ in {
];
file = {
".config/hypr/keybindings.info".text = lib.pipe (cfg.keybindings.bindings
".config/hypr/keybindings.info".text = lib.pipe (hyprland.keybindings.bindings
// always-bind) [
(builtins.mapAttrs mkBindsHelp)
builtins.attrValues
@ -213,7 +212,7 @@ in {
background = [
{
path = "~/NixFlake/wallpapers/${cfg.theme}.png";
path = "~/NixFlake/wallpapers/${hyprland.theme}.png";
blur_passes = 3;
blur_size = 10;
monitor = "";
@ -279,8 +278,8 @@ in {
splash = false;
splash_offset = 2.0;
preload = "~/NixFlake/wallpapers/${cfg.theme}.png";
wallpaper = lib.pipe cfg.monitors [
preload = "~/NixFlake/wallpapers/${hyprland.theme}.png";
wallpaper = lib.pipe hyprland.monitors [
builtins.attrNames
(builtins.map mkWallpaper)
];
@ -353,7 +352,7 @@ in {
xwayland.enable = true;
settings = {
"$mainMod" = "${cfg.keybindings.main-mod}";
"$mainMod" = "${hyprland.keybindings.main-mod}";
general = {
gaps_in = 5;
@ -380,8 +379,8 @@ in {
};
input = {
kb_layout = "${cfg.kb-layout}";
kb_variant = "${cfg.kb-variant}";
kb_layout = "${hyprland.kb-layout}";
kb_variant = "${hyprland.kb-variant}";
kb_model = "pc104";
kb_options = "";
kb_rules = "";
@ -395,18 +394,18 @@ in {
sensitivity = 0; # -1.0 - 1.0, 0 means no modification.
};
monitor = lib.pipe cfg.monitors [
monitor = lib.pipe hyprland.monitors [
(builtins.mapAttrs mkMonitor)
builtins.attrValues
];
workspace = lib.pipe cfg.workspaces [
workspace = lib.pipe hyprland.workspaces [
(builtins.mapAttrs mkWorkspaces)
builtins.attrValues
builtins.concatLists
];
bind = lib.pipe (cfg.keybindings.bindings
bind = lib.pipe (hyprland.keybindings.bindings
// always-bind) [
(builtins.mapAttrs mkBinds)
builtins.attrValues
@ -419,20 +418,20 @@ in {
builtins.concatLists
];
exec-once = lib.pipe (always-exec ++ cfg.autostart.immediate ++ delayed-exec) [
exec-once = lib.pipe (always-exec ++ hyprland.autostart.immediate ++ delayed-exec) [
(builtins.map mkExec)
];
windowrulev2 =
lib.pipe cfg.workspacerules [
lib.pipe hyprland.workspacerules [
(builtins.mapAttrs mkWorkspaceRules)
builtins.attrValues
builtins.concatLists
]
++ lib.pipe cfg.floating [
++ lib.pipe hyprland.floating [
(builtins.map mkFloatingRule)
]
++ lib.pipe cfg.transparent [
++ lib.pipe hyprland.transparent [
(builtins.map mkTranslucentRule)
];

View File

@ -4,16 +4,12 @@
lib,
mylib,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.kitty;
color = config.modules.color;
# cfgnv = config.modules.neovim;
}: let
inherit (config.modules) kitty color;
in {
options.modules.kitty = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf kitty.enable {
programs.kitty = {
enable = true;
shellIntegration.enableFishIntegration = true;

View File

@ -4,14 +4,12 @@
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.latex;
}: let
inherit (config.modules) latex;
in {
options.modules.latex = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf latex.enable {
home = {
packages = with pkgs; [
texliveFull

View File

@ -6,15 +6,12 @@
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.neovim;
color = config.modules.color;
}: let
inherit (config.modules) neovim color;
in {
options.modules.neovim = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf neovim.enable {
home = {
file.".config/neovide/config.toml".source = ./neovide_config.ini;
file.".config/vale/.vale.ini".source = ./vale_config.ini;
@ -80,8 +77,8 @@ in {
defaultEditor = true;
enableMan = false; # Nixvim man pages
luaLoader.enable = true; # NOTE: Experimental
viAlias = cfg.alias;
vimAlias = cfg.alias;
viAlias = neovim.alias;
vimAlias = neovim.alias;
# Configured using plugin
# colorschemes.catppuccin = {

View File

@ -1,19 +1,16 @@
# TODO: Expose some settings
{
config,
nixosConfig,
lib,
mylib,
pkgs,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.nnn;
}: let
inherit (config.modules) nnn;
in {
options.modules.nnn = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf nnn.enable {
home.sessionVariables = {
# NNN_TERMINAL = "alacritty";
# NNN_FIFO = "/tmp/nnn.fifo"; # For nnn preview

View File

@ -3,17 +3,17 @@
lib,
mylib,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.zathura;
}: let
inherit (config.modules) zathura;
in {
options.modules.zathura = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
config = lib.mkIf zathura.enable {
programs.zathura = {
enable = true;
# TODO: Set database backend
# TODO: Use color module
options = {
# Catppuccin Latte
default-fg = "#4C4F69";