diff --git a/config/home-manager/programs/gnome/default.nix b/config/home-manager/programs/gnome/default.nix index 005da1a..8e7b566 100644 --- a/config/home-manager/programs/gnome/default.nix +++ b/config/home-manager/programs/gnome/default.nix @@ -26,7 +26,7 @@ color-scheme = "prefer-dark"; }; "org/gnome/desktop/background" = { - picture-uri-dark = "file://" + builtins.toString osConfig.theme.wallpaper; + picture-uri-dark = "file://" + builtins.toString osConfig.local.style.wallpaper; }; "org/gnome/desktop/search-providers" = { diff --git a/config/home-manager/programs/swaybg.nix b/config/home-manager/programs/swaybg.nix index b81ef1d..f136e86 100644 --- a/config/home-manager/programs/swaybg.nix +++ b/config/home-manager/programs/swaybg.nix @@ -11,7 +11,7 @@ PartOf = ["graphical-session.target"]; }; Service = { - ExecStart = "${lib.getExe pkgs.swaybg} -i ${osConfig.theme.wallpaper} -m fill"; + ExecStart = "${lib.getExe pkgs.swaybg} -i ${osConfig.local.style.wallpaper} -m fill"; Restart = "on-failure"; }; Install.WantedBy = ["graphical-session.target"]; diff --git a/hosts/vamos/config/theme.nix b/hosts/vamos/config/theme.nix index 79c955f..0276822 100644 --- a/hosts/vamos/config/theme.nix +++ b/hosts/vamos/config/theme.nix @@ -1,5 +1,5 @@ {pkgs, ...}: { - theme = { + local.style = { enable = true; wallpaper = pkgs.fetchurl { url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/e0cf0eb237dc5baba86661a3572b20a6183c1876/wallpapers/nix-wallpaper-nineish-catppuccin-frappe.png?raw=true"; diff --git a/shared/nixosModules/default.nix b/shared/nixosModules/default.nix index a7c1dc4..8286746 100644 --- a/shared/nixosModules/default.nix +++ b/shared/nixosModules/default.nix @@ -2,6 +2,6 @@ imports = [ ./systemVars.nix ./homeVars.nix - ./theme + ./style ]; } diff --git a/shared/nixosModules/theme/default.nix b/shared/nixosModules/style/default.nix similarity index 93% rename from shared/nixosModules/theme/default.nix rename to shared/nixosModules/style/default.nix index ef0c691..e2c1fe1 100644 --- a/shared/nixosModules/theme/default.nix +++ b/shared/nixosModules/style/default.nix @@ -3,82 +3,29 @@ config, lib, lib', - pkgs, ... }: let - inherit (lib) mkEnableOption mkOption mkIf attrNames; + inherit (lib) mkIf; inherit (lib.strings) removePrefix; - inherit (lib.types) path package enum; inherit (lib') generateGtkColors; - cfg = config.theme; + cfg = config.local.style; in { imports = [ ./gtk.nix + ./options.nix inputs.niri.nixosModules.niri inputs.hyprland.nixosModules.default ]; - options.theme = { - enable = mkEnableOption "theme"; - schemeName = mkOption { - description = '' - Name of the tinted-theming color scheme to use. - ''; - type = enum (attrNames inputs.basix.schemeData.base16); - example = "catppuccin-mocha"; - default = "catppuccin-mocha"; - }; - - wallpaper = mkOption { - description = '' - Location of the wallpaper that will be used throughout the system. - ''; - type = path; - example = lib.literalExpression "./wallpaper.png"; - default = pkgs.fetchurl { - url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/e0cf0eb237dc5baba86661a3572b20a6183c1876/wallpapers/nix-wallpaper-nineish-catppuccin-frappe.png?raw=true"; - hash = "sha256-/HAtpGwLxjNfJvX5/4YZfM8jPNStaM3gisK8+ImRmQ4="; - }; - }; - - cursorTheme = { - name = mkOption { - description = '' - Name of the cursor theme. - ''; - default = "phinger-cursors-dark"; - }; - package = mkOption { - type = package; - description = '' - Package providing the cursor theme. - ''; - default = pkgs.phinger-cursors; - }; - size = mkOption { - description = '' - Size of the cursor. - ''; - default = 32; - }; - }; - - avatar = mkOption { - description = '' - Path to an avatar image (used for hyprlock). - ''; - default = ../../../assets/avatar.png; # TODO silly, change this - }; - }; config = let - scheme = inputs.basix.schemeData.base16.${config.theme.schemeName}; + scheme = inputs.basix.schemeData.base16.${cfg.schemeName}; in mkIf cfg.enable { - home-manager.users.nezia = { + home-manager.users.${config.local.systemVars.username} = { home.pointerCursor = { - inherit (config.theme.cursorTheme) name package size; + inherit (cfg.cursorTheme) name package size; x11.enable = true; gtk.enable = true; }; @@ -197,8 +144,8 @@ in { settings = { layout.focus-ring.active.color = scheme.palette.base0D; cursor = { - inherit (config.theme.cursorTheme) size; - theme = config.theme.cursorTheme.name; + inherit (cfg.cursorTheme) size; + theme = cfg.cursorTheme.name; }; }; }; @@ -670,6 +617,7 @@ in { stroke: var(--wave-color-solid-rainbow-purple-fill) !important; } ''; + gtk = rec { gtk3.extraConfig = { gtk-application-prefer-dark-theme = scheme.variant == "dark"; diff --git a/shared/nixosModules/style/gtk.nix b/shared/nixosModules/style/gtk.nix new file mode 100644 index 0000000..c281763 --- /dev/null +++ b/shared/nixosModules/style/gtk.nix @@ -0,0 +1,15 @@ +{config, ...}: let + cfg = config.local.style.gtk; +in { + home-manager.users.${config.local.systemVars.username} = { + gtk = { + enable = true; + iconTheme = { + inherit (cfg.iconTheme) name package; + }; + theme = { + inherit (cfg.theme) name package; + }; + }; + }; +} diff --git a/shared/nixosModules/style/options.nix b/shared/nixosModules/style/options.nix new file mode 100644 index 0000000..88538df --- /dev/null +++ b/shared/nixosModules/style/options.nix @@ -0,0 +1,129 @@ +{ + lib, + pkgs, + config, + options, + inputs, + ... +}: let + inherit (lib) attrNames mkEnableOption mkOption pathExists; + inherit (lib.types) bool enum package path str; + + cfg = config.local.style; +in { + options.local.style = { + enable = mkEnableOption "style"; + schemeName = mkOption { + description = '' + Name of the tinted-theming color scheme to use. + ''; + type = enum (attrNames inputs.basix.schemeData.base16); + example = "catppuccin-mocha"; + default = "catppuccin-mocha"; + }; + + wallpaper = mkOption { + description = '' + Location of the wallpaper that will be used throughout the system. + ''; + type = path; + example = lib.literalExpression "./wallpaper.png"; + default = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/e0cf0eb237dc5baba86661a3572b20a6183c1876/wallpapers/nix-wallpaper-nineish-catppuccin-frappe.png?raw=true"; + hash = "sha256-/HAtpGwLxjNfJvX5/4YZfM8jPNStaM3gisK8+ImRmQ4="; + }; + }; + + cursorTheme = { + name = mkOption { + description = '' + Name of the cursor theme. + ''; + default = "phinger-cursors-dark"; + }; + package = mkOption { + type = package; + description = '' + Package providing the cursor theme. + ''; + default = pkgs.phinger-cursors; + }; + size = mkOption { + description = '' + Size of the cursor. + ''; + default = 32; + }; + }; + + avatar = mkOption { + description = '' + Path to an avatar image (used for hyprlock). + ''; + default = ../../../assets/avatar.png; # TODO silly, change this + }; + + gtk = { + enable = mkOption { + type = bool; + description = "enable GTK theming options"; + default = cfg.enable; + }; + theme = { + name = mkOption { + type = str; + description = "Name for the GTK theme"; + default = "Catppuccin-GTK-Purple-Dark"; + }; + package = mkOption { + type = package; + description = "Package providing the GTK theme"; + + default = pkgs.magnetic-catppuccin-gtk.override { + accent = ["purple"]; + }; + }; + }; + + iconTheme = { + name = mkOption { + type = str; + description = "The name for the icon theme that will be used for GTK programs"; + default = "Papirus-Dark"; + }; + + package = mkOption { + type = package; + description = "The GTK icon theme to be used"; + default = pkgs.catppuccin-papirus-folders.override { + flavor = "mocha"; + accent = "lavender"; + }; + }; + }; + }; + }; + + config = { + assertions = [ + (let + themePath = cfg.gtk.theme.package + /share/themes + "/${cfg.gtk.theme.name}"; + in { + assertion = cfg.gtk.enable -> pathExists themePath; + message = '' + ${toString themePath} set by the GTK module does not exist! + + To suppress this message, make sure that + `config.modules.theme.gtk.theme.package` contains + the path `${cfg.theme.name}` + ''; + }) + { + assertion = cfg.enable -> options.local.systemVars.username.isDefined; + message = '' + When enabling system-wide theming, a username needs to be set in `config.local.systemVars.username`. + ''; + } + ]; + }; +} diff --git a/shared/nixosModules/theme/gtk.nix b/shared/nixosModules/theme/gtk.nix deleted file mode 100644 index 5480549..0000000 --- a/shared/nixosModules/theme/gtk.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib) mkOption pathExists; - inherit (lib.types) bool package str; - cfg = config.theme.gtk; -in { - options.theme.gtk = { - enable = mkOption { - type = bool; - description = "enable GTK theming options"; - default = config.theme.enable; - }; - theme = { - name = mkOption { - type = str; - description = "Name for the GTK theme"; - default = "Catppuccin-GTK-Purple-Dark"; - }; - package = mkOption { - type = package; - description = "Package providing the GTK theme"; - - default = pkgs.magnetic-catppuccin-gtk.override { - accent = ["purple"]; - }; - }; - }; - - iconTheme = { - name = mkOption { - type = str; - description = "The name for the icon theme that will be used for GTK programs"; - default = "Papirus-Dark"; - }; - - package = mkOption { - type = package; - description = "The GTK icon theme to be used"; - default = pkgs.catppuccin-papirus-folders.override { - flavor = "mocha"; - accent = "lavender"; - }; - }; - }; - }; - config = { - assertions = [ - (let - themePath = cfg.theme.package + /share/themes + "/${cfg.theme.name}"; - in { - assertion = cfg.enable -> pathExists themePath; - message = '' - ${toString themePath} set by the GTK module does not exist! - - To suppress this message, make sure that - `config.modules.theme.gtk.theme.package` contains - the path `${cfg.theme.name}` - ''; - }) - ]; - - home-manager.users.nezia = { - gtk = { - enable = true; - iconTheme = { - inherit (cfg.iconTheme) name package; - }; - theme = { - inherit (cfg.theme) name package; - }; - }; - }; - }; -}