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, mylib,
pkgs, pkgs,
... ...
}: }: let
with lib; inherit (config.modules) TEMPLATE;
with mylib.modules; let
cfg = config.modules.TEMPLATE;
in { in {
options.modules.TEMPLATE = import ./options.nix {inherit lib mylib;}; 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, mylib,
pkgs, pkgs,
... ...
}: }: let
with lib; inherit (config.modules) ags;
with mylib.modules; let
cfg = config.modules.ags;
in { in {
options.modules.ags = import ./options.nix {inherit lib mylib;}; options.modules.ags = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable { config = lib.mkIf ags.enable {
programs.ags = { programs.ags = {
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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