flocon/modules/options/style.nix
Anthony Rodriguez bb55875491
treewide: move shared/nixosModules to modules
The idea of this refactor is, as the configuration is getting bigger and
more complex, to move everything into a local modules system. The idea
is to simplify hosts declaration and add a new layer of abstraction to
avoid the long and redundant imports in hosts/default.nix, that I am
currently using.

First, we're going to move everything to the modules directory, and
split options from the proper configuration. That allows us to have an
easier time understanding how the options are structured, as they will
follow the directory structure and won't be mixed with the module
configuration.
2025-01-14 10:56:34 +01:00

138 lines
3.6 KiB
Nix

{
lib,
pkgs,
config,
options,
inputs,
...
}: let
inherit (lib) attrNames mkEnableOption mkOption pathExists;
inherit (lib.types) attrs 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";
};
scheme = mkOption {
description = ''
Computed scheme from `config.local.style.schemeName`.
'';
type = attrs;
readOnly = true;
};
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`.
'';
}
];
local.style.scheme = inputs.basix.schemeData.base16.${cfg.schemeName};
};
}