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

View file

@ -1,9 +1,30 @@
{ 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
]; ];
config = lib.mkIf cfg.enable {
stylix = { stylix = {
enable = true; enable = true;
image = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png"; image = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png";
@ -37,4 +58,11 @@
size = 26; size = 26;
}; };
}; };
assertions = [
{
assertion = builtins.hasAttr cfg.stylixName inputs;
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.'';
}
];
};
} }

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.'';
}
];
} }