Files
nix-config/host/pc/common/stylix.nix
T

83 lines
2.5 KiB
Nix

{
inputs,
lib,
pkgs,
userName,
...
}:
let
jsonSchemes = pkgs.stdenv.mkDerivation {
name = "fromYAML";
phases = "buildPhase";
buildPhase = ''
mkdir -p $out/
for FILE in ${pkgs.base16-schemes}/share/themes/*; do
FILEBASENAME="$(basename $FILE .yaml).json"
cat $FILE | ${pkgs.yaml2json}/bin/yaml2json | sed s/#//g > $out/$FILEBASENAME
done
ls -l $out/
'';
};
json2Palette =
jsonScheme: (builtins.fromJSON (builtins.readFile "${jsonSchemes}/${jsonScheme}.json")).palette;
font = {
package = pkgs.nerd-fonts.caskaydia-cove;
name = "CaskaydiaCove Nerd Font";
};
makeTheme =
jsonScheme: polarity:
let
palette = json2Palette jsonScheme;
in
{
enable = true;
base16Scheme.palette = palette;
inherit polarity;
fonts = {
emoji = font;
monospace = font;
sansSerif = font;
serif = font;
};
image =
let
wallpaper = inputs.nix-wallpaper.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
width = 2560;
height = 1440;
backgroundColor = "#${palette.base00}";
logoColors = {
color0 = "#${palette.base0D}";
color1 = "#${palette.base0D}";
color2 = "#${palette.base0D}";
color3 = "#${palette.base0D}";
color4 = "#${palette.base0D}";
color5 = "#${palette.base0D}";
};
};
in
"${wallpaper}/share/wallpapers/nixos-wallpaper.png";
};
in
{
stylix = makeTheme "catppuccin-mocha" "dark";
specialisation = {
catppuccin-mocha.configuration.stylix = lib.mkForce (makeTheme "catppuccin-mocha" "dark");
catppuccin-latte.configuration.stylix = lib.mkForce (makeTheme "catppuccin-latte" "light");
gruvbox-dark-hard.configuration.stylix = lib.mkForce (makeTheme "gruvbox-dark-hard" "dark");
heetch.configuration.stylix = lib.mkForce (makeTheme "heetch" "dark");
};
security.sudo.extraConfig = ''
${userName} ALL = (root) NOPASSWD: /nix/var/nix/profiles/system/specialisation/catppuccin-mocha/bin/switch-to-configuration
${userName} ALL = (root) NOPASSWD: /nix/var/nix/profiles/system/specialisation/catppuccin-latte/bin/switch-to-configuration
${userName} ALL = (root) NOPASSWD: /nix/var/nix/profiles/system/specialisation/gruvbox-dark-hard/bin/switch-to-configuration
${userName} ALL = (root) NOPASSWD: /nix/var/nix/profiles/system/specialisation/heetch/bin/switch-to-configuration
'';
}