refactor: modularize theming

This commit is contained in:
Youwen Wu 2024-12-22 23:26:13 -08:00
parent ddfcbd78c8
commit 4c72a5cb8b
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
5 changed files with 102 additions and 53 deletions

View file

@ -22,6 +22,10 @@
firewallPresets.vite = true; firewallPresets.vite = true;
cloudflareNameservers.enable = true; cloudflareNameservers.enable = true;
}; };
fonts.enable = true;
};
theming = {
enable = true;
}; };
}; };

View file

@ -11,7 +11,6 @@
../../modules/linux/networking ../../modules/linux/networking
../../modules/linux/fonts ../../modules/linux/fonts
../../modules/linux/greeter ../../modules/linux/greeter
# ../../modules/linux/spotifyd
../../modules/linux/core ../../modules/linux/core
../../modules/linux/desktop-portal ../../modules/linux/desktop-portal
../../modules/linux/stylix ../../modules/linux/stylix

View file

@ -1,19 +1,31 @@
{ pkgs, ... }:
{ {
fonts = { pkgs,
enableDefaultPackages = true; lib,
# fontconfig = { config,
# defaultFonts = { ...
# serif = [ "Noto Serif" ]; }:
# sansSerif = [ "Noto Sans" ]; let
# }; cfg = config.liminalOS.system.fonts;
# }; in
packages = with pkgs; [ {
# noto-fonts options.liminalOS.system.fonts = {
noto-fonts-cjk-sans enable = lib.mkEnableOption "fonts";
# noto-fonts-emoji };
# (nerdfonts.override { fonts = [ "CascadiaCode" ]; })
(google-fonts.override { fonts = [ "Lora" ]; }) config = lib.mkIf cfg.enable {
]; fonts = {
enableDefaultPackages = true;
packages =
with pkgs;
[
noto-fonts-cjk-sans
(google-fonts.override { fonts = [ "Lora" ]; })
]
++ (lib.optionals (!config.liminalOS.theming.enable) [
noto-fonts
noto-fonts-emoji
nerd-fonts.caskaydia-cove
]);
};
}; };
} }

View file

@ -1,40 +1,68 @@
{ inputs, pkgs, ... }:
{ {
inputs,
pkgs,
config,
lib,
...
}:
let
cfg = config.liminalOS.theming;
in
{
options.liminalOS.theming = {
enable = lib.mkEnableOption "theming";
stylixName = lib.mkOption {
type = lib.types.str;
default = "stylix";
description = ''
Name of Stylix module defined in `inputs`. Defaults to `stylix`. You must define `inputs.stylix.url` in your `flake.nix` to enable this option
'';
};
};
imports = [ imports = [
inputs.stylix.nixosModules.stylix inputs.stylix.nixosModules.stylix
]; ];
stylix = { config = lib.mkIf cfg.enable {
enable = true; stylix = {
image = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png"; enable = true;
# image = "${inputs.wallpapers}/aesthetic/red_deadly_sun.jpg"; image = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png";
# image = "${inputs.wallpapers}/aesthetic/afterglow_sand_dunes.jpg"; # image = "${inputs.wallpapers}/aesthetic/red_deadly_sun.jpg";
base16Scheme = "${pkgs.base16-schemes}/share/themes/rose-pine.yaml"; # image = "${inputs.wallpapers}/aesthetic/afterglow_sand_dunes.jpg";
polarity = "dark"; base16Scheme = "${pkgs.base16-schemes}/share/themes/rose-pine.yaml";
polarity = "dark";
fonts = { fonts = {
serif = { serif = {
name = "Noto Serif"; name = "Noto Serif";
package = pkgs.noto-fonts; package = pkgs.noto-fonts;
};
sansSerif = {
name = "Noto Sans";
package = pkgs.noto-fonts;
};
emoji = {
name = "Noto Color Emoji";
package = pkgs.noto-fonts-emoji;
};
monospace = {
name = "CaskaydiaCove Nerd Font";
package = pkgs.nerd-fonts.caskaydia-cove;
};
}; };
sansSerif = {
name = "Noto Sans"; cursor = {
package = pkgs.noto-fonts; package = pkgs.bibata-cursors;
}; name = "Bibata-Modern-Ice";
emoji = { size = 26;
name = "Noto Color Emoji";
package = pkgs.noto-fonts-emoji;
};
monospace = {
name = "CaskaydiaCove Nerd Font";
package = pkgs.nerd-fonts.caskaydia-cove;
}; };
}; };
assertions = [
cursor = { {
package = pkgs.bibata-cursors; assertion = builtins.hasAttr cfg.stylixName inputs;
name = "Bibata-Modern-Ice"; message = ''You enabled theming but did not add a Stylix module to your flake inputs, or did not set `liminalOS.theming.stylixName` to the name of your Stylix input, if it is not `stylix`. Please set `inputs.stylix.url = "github:danth/stylix"` or set the stylixName option to the name of your stylix flake input.'';
size = 26; }
}; ];
}; };
} }

View file

@ -8,17 +8,17 @@ let
cfg = config.liminalOS.wsl; cfg = config.liminalOS.wsl;
in in
{ {
imports = lib.mkIf cfg.enable [ imports = [
inputs.nixos-wsl.nixosModules.default inputs.${cfg.wslName}.nixosModules.default
]; ];
options = { options = {
enable = lib.mkEnableOption "wsl"; enable = lib.mkEnableOption "WSL";
module = lib.mkOption { wslName = lib.mkOption {
type = lib.types.submodule; type = lib.types.str;
default = inputs.nixos-wsl.nixosModules.default; default = "nixos-wsl";
description = '' description = ''
NixOS WSL module. Defaults to <https://github.com/nix-community/NixOS-WSL> Name of the NixOS WSL module in your flake inputs. You should define `inputs.nixos-wsl.url = "github:nixos-community/nixos-wsl", and set `liminalOS.wsl.wslName` if you did not call it `nixos-wsl`.
''; '';
}; };
}; };
@ -28,4 +28,10 @@ in
defaultUser = config.liminalOS.username; defaultUser = config.liminalOS.username;
useWindowsDriver = true; useWindowsDriver = true;
}; };
assertions = [
{
assertion = builtins.hasAttr cfg.wslName inputs;
message = ''You enabled WSL but did not add the WSL module to your flake inputs, or did not set `liminalOS.theming.wslName` to the name of your NixOS WSL input, if it is not `nixos-wsl`. Please set `inputs.nixos-wsl.url = "github:nix-community/nixos-wsl"` or set the wslName option to the name of your WSL flake input.'';
}
];
} }