treewide: split up options from theming module, rename to style
As an initial step towards refactoring the theming module, the options have been split up from the configuration itself. This will allow to find available options quicker, and separate concerns nicely. It was also renamed to style, to avoid confusion with its own options (eg. gtk.theme).
This commit is contained in:
parent
87bb04f065
commit
587e8d321b
8 changed files with 157 additions and 143 deletions
|
@ -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" = {
|
||||
|
|
|
@ -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"];
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
imports = [
|
||||
./systemVars.nix
|
||||
./homeVars.nix
|
||||
./theme
|
||||
./style
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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";
|
15
shared/nixosModules/style/gtk.nix
Normal file
15
shared/nixosModules/style/gtk.nix
Normal file
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
129
shared/nixosModules/style/options.nix
Normal file
129
shared/nixosModules/style/options.nix
Normal file
|
@ -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`.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue