refactor: use alternatives to with
and rec
(#38)
* fix(home-manager): dont declare xdg.configFile when btop isn't enabled * refactor: use alternatives to `with` and `rec` --------- Co-authored-by: Sam Nystrom <sam@samnystrom.dev>
This commit is contained in:
parent
9616836d65
commit
60a1d9ba22
17 changed files with 306 additions and 200 deletions
|
@ -1,21 +1,28 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.alacritty.catppuccin;
|
, pkgs
|
||||||
in {
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) ctp;
|
||||||
|
cfg = config.programs.alacritty.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.alacritty.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
options.programs.alacritty.catppuccin =
|
options.programs.alacritty.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "alacritty" config;
|
ctp.mkCatppuccinOpt "alacritty" config;
|
||||||
|
|
||||||
config.programs.alacritty.settings = with builtins;
|
config.programs.alacritty.settings =
|
||||||
with lib;
|
|
||||||
with pkgs;
|
|
||||||
let
|
let
|
||||||
file = fetchFromGitHub
|
file =
|
||||||
{
|
pkgs.fetchFromGitHub
|
||||||
owner = "catppuccin";
|
{
|
||||||
repo = "alacritty";
|
owner = "catppuccin";
|
||||||
rev = "3c808cbb4f9c87be43ba5241bc57373c793d2f17";
|
repo = "alacritty";
|
||||||
sha256 = "sha256-w9XVtEe7TqzxxGUCDUR9BFkzLZjG8XrplXJ3lX6f+x0=";
|
rev = "3c808cbb4f9c87be43ba5241bc57373c793d2f17";
|
||||||
} + "/catppuccin-${cfg.flavour}.yml";
|
sha256 = "sha256-w9XVtEe7TqzxxGUCDUR9BFkzLZjG8XrplXJ3lX6f+x0=";
|
||||||
|
}
|
||||||
|
+ "/catppuccin-${cfg.flavour}.yml";
|
||||||
in
|
in
|
||||||
mkIf cfg.enable (ctp.fromYaml pkgs file);
|
lib.mkIf enable (ctp.fromYaml pkgs file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.bat.catppuccin; in
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.programs.bat.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.bat.enable;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
options.programs.bat.catppuccin =
|
options.programs.bat.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "bat" config;
|
lib.ctp.mkCatppuccinOpt "bat" config;
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
programs.bat = lib.mkIf cfg.enable {
|
programs.bat = lib.mkIf enable {
|
||||||
config.theme = "Catppuccin-${cfg.flavour}";
|
config.theme = "Catppuccin-${cfg.flavour}";
|
||||||
themes."Catppuccin-${cfg.flavour}" = builtins.readFile (pkgs.fetchFromGitHub
|
themes."Catppuccin-${cfg.flavour}" = builtins.readFile (pkgs.fetchFromGitHub
|
||||||
{
|
{
|
||||||
|
@ -13,7 +20,8 @@ let cfg = config.programs.bat.catppuccin; in
|
||||||
repo = "bat";
|
repo = "bat";
|
||||||
rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1";
|
rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1";
|
||||||
sha256 = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw=";
|
sha256 = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw=";
|
||||||
} + /Catppuccin-${cfg.flavour}.tmTheme);
|
}
|
||||||
|
+ "/Catppuccin-${cfg.flavour}.tmTheme");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.bottom.catppuccin;
|
, pkgs
|
||||||
in {
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (builtins) fromTOML readFile;
|
||||||
|
cfg = config.programs.bottom.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.bottom.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
options.programs.bottom.catppuccin =
|
options.programs.bottom.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "bottom" config;
|
lib.ctp.mkCatppuccinOpt "bottom" config;
|
||||||
|
|
||||||
config.programs.bottom.settings = with builtins;
|
config.programs.bottom.settings = lib.mkIf enable (fromTOML (readFile (pkgs.fetchFromGitHub
|
||||||
with lib;
|
{
|
||||||
with pkgs;
|
owner = "catppuccin";
|
||||||
mkIf cfg.enable (fromTOML (readFile (fetchFromGitHub
|
repo = "bottom";
|
||||||
{
|
rev = "c0efe9025f62f618a407999d89b04a231ba99c92";
|
||||||
owner = "catppuccin";
|
sha256 = "sha256-VaHX2I/Gn82wJWzybpWNqU3dPi3206xItOlt0iF6VVQ=";
|
||||||
repo = "bottom";
|
}
|
||||||
rev = "c0efe9025f62f618a407999d89b04a231ba99c92";
|
+ "/themes/${cfg.flavour}.toml")));
|
||||||
sha256 = "sha256-VaHX2I/Gn82wJWzybpWNqU3dPi3206xItOlt0iF6VVQ=";
|
|
||||||
} + "/themes/${cfg.flavour}.toml")));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
inherit (lib) mkIf;
|
||||||
cfg = config.programs.btop.catppuccin;
|
cfg = config.programs.btop.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.btop.enable;
|
||||||
|
|
||||||
themePath = "/themes/catppuccin_${cfg.flavour}.theme";
|
themePath = "/themes/catppuccin_${cfg.flavour}.theme";
|
||||||
theme =
|
theme =
|
||||||
pkgs.fetchFromGitHub
|
pkgs.fetchFromGitHub
|
||||||
|
@ -23,12 +26,12 @@ in
|
||||||
# xdg is required for this to work
|
# xdg is required for this to work
|
||||||
config =
|
config =
|
||||||
{
|
{
|
||||||
xdg.enable = with lib; mkIf cfg.enable (mkForce true);
|
xdg.enable = mkIf enable (lib.mkForce true);
|
||||||
|
|
||||||
programs.btop.settings.color_theme = with lib;
|
programs.btop.settings.color_theme =
|
||||||
mkIf cfg.enable "${config.xdg.configHome + "/btop/${themePath}"}";
|
mkIf enable "${config.xdg.configHome + "/btop/${themePath}"}";
|
||||||
}
|
}
|
||||||
// (lib.mkIf cfg.enable {
|
// (lib.mkIf enable {
|
||||||
xdg.configFile."btop${themePath}".source = theme;
|
xdg.configFile."btop${themePath}".source = theme;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
nixpkgs: { config, pkgs, lib, ... }:
|
nixpkgs: { config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
extendedLib = import ../lib/mkExtLib.nix nixpkgs.lib;
|
extendedLib = import ../lib/mkExtLib.nix nixpkgs.lib;
|
||||||
|
inherit (extendedLib) ctp;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
|
@ -23,13 +28,13 @@ in
|
||||||
in
|
in
|
||||||
extendedLib.ctp.mapModules config pkgs extendedLib files;
|
extendedLib.ctp.mapModules config pkgs extendedLib files;
|
||||||
|
|
||||||
options.catppuccin = with extendedLib; {
|
options.catppuccin = {
|
||||||
flavour = mkOption {
|
flavour = lib.mkOption {
|
||||||
type = ctp.types.flavourOption;
|
type = ctp.types.flavourOption;
|
||||||
default = "latte";
|
default = "latte";
|
||||||
description = "Global Catppuccin flavour";
|
description = "Global Catppuccin flavour";
|
||||||
};
|
};
|
||||||
accent = mkOption {
|
accent = lib.mkOption {
|
||||||
type = ctp.types.accentOption;
|
type = ctp.types.accentOption;
|
||||||
default = "teal";
|
default = "teal";
|
||||||
description = "Global Catppuccin accent";
|
description = "Global Catppuccin accent";
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.gtk.catppuccin;
|
, pkgs
|
||||||
in {
|
, lib
|
||||||
options.gtk.catppuccin = with lib;
|
, ...
|
||||||
ctp.mkCatppuccinOpt "gtk" config // {
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) ctp mkOption types;
|
||||||
|
cfg = config.gtk.catppuccin;
|
||||||
|
enable = cfg.enable && config.gtk.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.gtk.catppuccin =
|
||||||
|
ctp.mkCatppuccinOpt "gtk" config
|
||||||
|
// {
|
||||||
accent = ctp.mkAccentOpt "gtk" config;
|
accent = ctp.mkAccentOpt "gtk" config;
|
||||||
size = mkOption {
|
size = mkOption {
|
||||||
type = types.enum [ "standard" "compact" ];
|
type = types.enum [ "standard" "compact" ];
|
||||||
|
@ -16,20 +25,20 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.gtk.theme = with builtins;
|
config.gtk.theme =
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
flavourUpper = ctp.mkUpper cfg.flavour;
|
flavourUpper = ctp.mkUpper cfg.flavour;
|
||||||
accentUpper = ctp.mkUpper cfg.accent;
|
accentUpper = ctp.mkUpper cfg.accent;
|
||||||
sizeUpper = ctp.mkUpper cfg.size;
|
sizeUpper = ctp.mkUpper cfg.size;
|
||||||
|
|
||||||
# use the light gtk theme for latte
|
# use the light gtk theme for latte
|
||||||
gtkTheme = if cfg.flavour == "latte" then "Light" else "Dark";
|
gtkTheme =
|
||||||
|
if cfg.flavour == "latte"
|
||||||
|
then "Light"
|
||||||
|
else "Dark";
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
lib.mkIf enable {
|
||||||
name =
|
name = "Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}";
|
||||||
"Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}";
|
|
||||||
package = pkgs.catppuccin-gtk.override {
|
package = pkgs.catppuccin-gtk.override {
|
||||||
inherit (cfg) size tweaks;
|
inherit (cfg) size tweaks;
|
||||||
accents = [ cfg.accent ];
|
accents = [ cfg.accent ];
|
||||||
|
|
|
@ -1,26 +1,40 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.helix.catppuccin;
|
, pkgs
|
||||||
in {
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (builtins) fromTOML readFile;
|
||||||
|
cfg = config.programs.helix.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.helix.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
options.programs.helix.catppuccin = with lib;
|
options.programs.helix.catppuccin = with lib;
|
||||||
ctp.mkCatppuccinOpt "helix" config // {
|
ctp.mkCatppuccinOpt "helix" config
|
||||||
|
// {
|
||||||
useItalics = mkEnableOption "Italics in Catppuccin theme for Helix";
|
useItalics = mkEnableOption "Italics in Catppuccin theme for Helix";
|
||||||
};
|
};
|
||||||
|
|
||||||
config.programs.helix = with builtins;
|
config.programs.helix =
|
||||||
with lib;
|
let
|
||||||
with pkgs;
|
subdir =
|
||||||
let subdir = if cfg.useItalics then "default" else "no_italics";
|
if cfg.useItalics
|
||||||
in mkIf cfg.enable {
|
then "default"
|
||||||
|
else "no_italics";
|
||||||
|
in
|
||||||
|
lib.mkIf enable {
|
||||||
settings = {
|
settings = {
|
||||||
theme = "catppuccin-${cfg.flavour}";
|
theme = "catppuccin-${cfg.flavour}";
|
||||||
editor.color-modes = mkDefault true;
|
editor.color-modes = lib.mkDefault true;
|
||||||
};
|
};
|
||||||
themes."catppuccin-${cfg.flavour}" = fromTOML (readFile (fetchFromGitHub
|
|
||||||
|
themes."catppuccin-${cfg.flavour}" = fromTOML (readFile (pkgs.fetchFromGitHub
|
||||||
{
|
{
|
||||||
owner = "catppuccin";
|
owner = "catppuccin";
|
||||||
repo = "helix";
|
repo = "helix";
|
||||||
rev = "5677c16dc95297a804caea9161072ff174018fdd";
|
rev = "5677c16dc95297a804caea9161072ff174018fdd";
|
||||||
sha256 = "sha256-aa8KZ7/1TXcBqaV/TYOZ8rpusOf5QeQ9i2Upnncbziw=";
|
sha256 = "sha256-aa8KZ7/1TXcBqaV/TYOZ8rpusOf5QeQ9i2Upnncbziw=";
|
||||||
} + "/themes/${subdir}/catppuccin_${cfg.flavour}.toml"));
|
}
|
||||||
|
+ "/themes/${subdir}/catppuccin_${cfg.flavour}.toml"));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
{ config, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.kitty.catppuccin;
|
, lib
|
||||||
in {
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) ctp;
|
||||||
|
cfg = config.programs.kitty.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.kitty.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
options.programs.kitty.catppuccin =
|
options.programs.kitty.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "kitty" config;
|
ctp.mkCatppuccinOpt "kitty" config;
|
||||||
|
|
||||||
config.programs.kitty = with lib;
|
config.programs.kitty =
|
||||||
let flavourUpper = ctp.mkUpper cfg.flavour;
|
lib.mkIf enable { theme = "Catppuccin-${ctp.mkUpper cfg.flavour}"; };
|
||||||
in mkIf cfg.enable { theme = "Catppuccin-${flavourUpper}"; };
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,27 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.lazygit.catppuccin;
|
, pkgs
|
||||||
in {
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.programs.lazygit.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.lazygit.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
options.programs.lazygit.catppuccin =
|
options.programs.lazygit.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "lazygit" config;
|
lib.ctp.mkCatppuccinOpt "lazygit" config;
|
||||||
|
|
||||||
config.programs.lazygit.settings = with builtins;
|
config.programs.lazygit.settings =
|
||||||
with lib;
|
|
||||||
with pkgs;
|
|
||||||
let
|
let
|
||||||
file = fetchFromGitHub
|
file =
|
||||||
{
|
pkgs.fetchFromGitHub
|
||||||
owner = "catppuccin";
|
{
|
||||||
repo = "lazygit";
|
owner = "catppuccin";
|
||||||
rev = "f01edfd57fa2aa7cd69a92537a613bb3c91e65dd";
|
repo = "lazygit";
|
||||||
sha256 = "sha256-zjzDtXcGtUon4QbrZnlAPzngEyH56yy8TCyFv0rIbOA=";
|
rev = "f01edfd57fa2aa7cd69a92537a613bb3c91e65dd";
|
||||||
} + "/themes/${cfg.flavour}.yml";
|
sha256 = "sha256-zjzDtXcGtUon4QbrZnlAPzngEyH56yy8TCyFv0rIbOA=";
|
||||||
|
}
|
||||||
|
+ "/themes/${cfg.flavour}.yml";
|
||||||
in
|
in
|
||||||
mkIf cfg.enable (ctp.fromYaml pkgs file);
|
lib.mkIf enable (lib.ctp.fromYaml pkgs file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.programs.neovim.catppuccin;
|
cfg = config.programs.neovim.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.neovim.enable;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.neovim.catppuccin = lib.ctp.mkCatppuccinOpt "neovim" config;
|
options.programs.neovim.catppuccin = lib.ctp.mkCatppuccinOpt "neovim" config;
|
||||||
|
|
||||||
config.programs.neovim = with lib; mkIf cfg.enable {
|
config.programs.neovim = lib.mkIf enable {
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = with pkgs.vimPlugins; [
|
||||||
{
|
{
|
||||||
plugin = catppuccin-nvim;
|
plugin = catppuccin-nvim;
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.services.polybar.catppuccin;
|
, pkgs
|
||||||
in {
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.services.polybar.catppuccin;
|
||||||
|
enable = cfg.enable && config.services.polybar.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
options.services.polybar.catppuccin =
|
options.services.polybar.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "polybar" config;
|
lib.ctp.mkCatppuccinOpt "polybar" config;
|
||||||
|
|
||||||
config.services.polybar.extraConfig = with builtins;
|
config.services.polybar.extraConfig = lib.mkIf enable (builtins.readFile (pkgs.fetchFromGitHub
|
||||||
with lib;
|
{
|
||||||
with pkgs;
|
owner = "catppuccin";
|
||||||
mkIf cfg.enable (readFile (fetchFromGitHub
|
repo = "polybar";
|
||||||
{
|
rev = "9ee66f83335404186ce979bac32fcf3cd047396a";
|
||||||
owner = "catppuccin";
|
sha256 = "sha256-bUbSgMg/sa2faeEUZo80GNmhOX3wn2jLzfA9neF8ERA=";
|
||||||
repo = "polybar";
|
}
|
||||||
rev = "9ee66f83335404186ce979bac32fcf3cd047396a";
|
+ "/themes/${cfg.flavour}.ini"));
|
||||||
sha256 = "sha256-bUbSgMg/sa2faeEUZo80GNmhOX3wn2jLzfA9neF8ERA=";
|
|
||||||
} + "/themes/${cfg.flavour}.ini"));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,30 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
let cfg = config.programs.starship.catppuccin; in
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (builtins) fromTOML readFile;
|
||||||
|
cfg = config.programs.starship.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.starship.enable;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
options.programs.starship.catppuccin =
|
options.programs.starship.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "starship" config;
|
lib.ctp.mkCatppuccinOpt "starship" config;
|
||||||
|
|
||||||
config.programs.starship.settings = lib.mkIf cfg.enable
|
config.programs.starship.settings =
|
||||||
({
|
lib.mkIf enable
|
||||||
format = lib.mkDefault "$all";
|
({
|
||||||
palette = "catppuccin_${cfg.flavour}";
|
format = lib.mkDefault "$all";
|
||||||
} // builtins.fromTOML (builtins.readFile
|
palette = "catppuccin_${cfg.flavour}";
|
||||||
(pkgs.fetchFromGitHub
|
}
|
||||||
{
|
// fromTOML (readFile
|
||||||
owner = "catppuccin";
|
(pkgs.fetchFromGitHub
|
||||||
repo = "starship";
|
{
|
||||||
rev = "3e3e54410c3189053f4da7a7043261361a1ed1bc";
|
owner = "catppuccin";
|
||||||
sha256 = "sha256-soEBVlq3ULeiZFAdQYMRFuswIIhI9bclIU8WXjxd7oY=";
|
repo = "starship";
|
||||||
} + /palettes/${cfg.flavour}.toml)));
|
rev = "3e3e54410c3189053f4da7a7043261361a1ed1bc";
|
||||||
|
sha256 = "sha256-soEBVlq3ULeiZFAdQYMRFuswIIhI9bclIU8WXjxd7oY=";
|
||||||
|
}
|
||||||
|
+ "/palettes/${cfg.flavour}.toml")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.wayland.windowManager.sway.catppuccin;
|
cfg = config.wayland.windowManager.sway.catppuccin;
|
||||||
theme = pkgs.fetchFromGitHub
|
enable = cfg.enable && config.wayland.windowManager.sway.enable;
|
||||||
{
|
theme =
|
||||||
owner = "catppuccin";
|
pkgs.fetchFromGitHub
|
||||||
repo = "sway";
|
{
|
||||||
rev = "c89098fc3517b64f0422aaaccb98dcab6ae9348f";
|
owner = "catppuccin";
|
||||||
sha256 = "sha256-6Cvsmdl3OILz1vZovyBIuuSpm207I3W0dmUGowR9Ugk=";
|
repo = "sway";
|
||||||
} + "/themes/catppuccin-${cfg.flavour}";
|
rev = "c89098fc3517b64f0422aaaccb98dcab6ae9348f";
|
||||||
|
sha256 = "sha256-6Cvsmdl3OILz1vZovyBIuuSpm207I3W0dmUGowR9Ugk=";
|
||||||
|
}
|
||||||
|
+ "/themes/catppuccin-${cfg.flavour}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.wayland.windowManager.sway.catppuccin =
|
options.wayland.windowManager.sway.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "sway" config;
|
lib.ctp.mkCatppuccinOpt "sway" config;
|
||||||
|
|
||||||
config.wayland.windowManager.sway.extraConfigEarly = with lib;
|
config.wayland.windowManager.sway.extraConfigEarly =
|
||||||
with builtins;
|
lib.mkIf enable (builtins.readFile theme);
|
||||||
mkIf cfg.enable (readFile theme);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.programs.tmux.catppuccin;
|
cfg = config.programs.tmux.catppuccin;
|
||||||
|
enable = cfg.enable && config.programs.tmux.enable;
|
||||||
|
|
||||||
plugin = with builtins;
|
plugin = with builtins;
|
||||||
with pkgs;
|
with pkgs; let
|
||||||
let rev = "4e48b09a76829edc7b55fbb15467cf0411f07931";
|
rev = "4e48b09a76829edc7b55fbb15467cf0411f07931";
|
||||||
in tmuxPlugins.mkTmuxPlugin {
|
in
|
||||||
|
tmuxPlugins.mkTmuxPlugin {
|
||||||
pluginName = "catppuccin";
|
pluginName = "catppuccin";
|
||||||
version = substring 0 7 rev;
|
version = substring 0 7 rev;
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
|
@ -20,7 +26,7 @@ in
|
||||||
options.programs.tmux.catppuccin =
|
options.programs.tmux.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "tmux" config;
|
lib.ctp.mkCatppuccinOpt "tmux" config;
|
||||||
|
|
||||||
config.programs.tmux.plugins = with lib; mkIf cfg.enable [
|
config.programs.tmux.plugins = lib.mkIf enable [
|
||||||
{
|
{
|
||||||
inherit plugin;
|
inherit plugin;
|
||||||
extraConfig = "set -g @catppuccin_flavour '${cfg.flavour}'";
|
extraConfig = "set -g @catppuccin_flavour '${cfg.flavour}'";
|
||||||
|
|
|
@ -1,34 +1,23 @@
|
||||||
lib:
|
lib:
|
||||||
with builtins;
|
let
|
||||||
with lib; rec {
|
# string -> type -> string -> a -> a
|
||||||
# string -> string
|
# this is an internal function and shouldn't be
|
||||||
# this capitalizes the first letter in a string,
|
# used unless you know what you're doing. it takes
|
||||||
# which is sometimes needed in order to format
|
# a string (the name of the property, i.e., flavour
|
||||||
# the names of themes correctly
|
# or accent), the type of the property, the name of
|
||||||
mkUpper = str:
|
# the module, followed by local config attrset
|
||||||
(toUpper (substring 0 1 str)) + (substring 1 (stringLength str) str);
|
mkBasicOpt = attr: type: name: config:
|
||||||
|
lib.mkOption {
|
||||||
|
inherit type;
|
||||||
|
default = config.catppuccin.${attr};
|
||||||
|
description = "Catppuccin ${attr} for ${name}";
|
||||||
|
};
|
||||||
|
|
||||||
# a -> path -> a
|
# string -> a -> a
|
||||||
# fromJSON but for yaml (and without readFile)
|
# this creates a flavour option for modules
|
||||||
# a should be the local pkgs attrset
|
# the first string should be the name of the module,
|
||||||
fromYaml = pkgs: file:
|
# followed by the local config attrset
|
||||||
let
|
mkFlavourOpt = mkBasicOpt "flavour" types.flavourOption;
|
||||||
# convert to json
|
|
||||||
json = with pkgs; runCommand "converted.json" { } ''
|
|
||||||
${yj}/bin/yj < ${file} > $out
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
fromJSON (readFile json);
|
|
||||||
|
|
||||||
# a -> a -> [path] -> [path]
|
|
||||||
# this imports a list of paths while inheriting
|
|
||||||
# multiple attributes
|
|
||||||
mapModules = config: pkgs: extendedLib:
|
|
||||||
map (m:
|
|
||||||
(import m {
|
|
||||||
inherit config pkgs;
|
|
||||||
lib = extendedLib;
|
|
||||||
}));
|
|
||||||
|
|
||||||
types = {
|
types = {
|
||||||
flavourOption = lib.types.enum [ "latte" "frappe" "macchiato" "mocha" ];
|
flavourOption = lib.types.enum [ "latte" "frappe" "macchiato" "mocha" ];
|
||||||
|
@ -49,31 +38,41 @@ with lib; rec {
|
||||||
"yellow"
|
"yellow"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit mkBasicOpt mkFlavourOpt types;
|
||||||
|
|
||||||
# string -> type -> string -> a -> a
|
# string -> string
|
||||||
# this is an internal function and shouldn't be
|
# this capitalizes the first letter in a string,
|
||||||
# used unless you know what you're doing. it takes
|
# which is sometimes needed in order to format
|
||||||
# a string (the name of the property, i.e., flavour
|
# the names of themes correctly
|
||||||
# or accent), the type of the property, the name of
|
mkUpper = str:
|
||||||
# the module, followed by local config attrset
|
with builtins;
|
||||||
mkBasicOpt = attr: type: name: config:
|
(lib.toUpper (substring 0 1 str)) + (substring 1 (stringLength str) str);
|
||||||
mkOption {
|
|
||||||
inherit type;
|
|
||||||
default = config.catppuccin.${attr};
|
|
||||||
description = "Catppuccin ${attr} for ${name}";
|
|
||||||
};
|
|
||||||
|
|
||||||
# string -> a -> a
|
# a -> path -> a
|
||||||
# this creates a flavour option for modules
|
# fromJSON but for yaml (and without readFile)
|
||||||
# the first string should be the name of the module,
|
# a should be the local pkgs attrset
|
||||||
# followed by the local config attrset
|
fromYaml = pkgs: file:
|
||||||
mkFlavourOpt = mkBasicOpt "flavour" types.flavourOption;
|
let
|
||||||
|
inherit (builtins) fromJSON readFile;
|
||||||
|
|
||||||
# string -> a -> a
|
# convert to json
|
||||||
# this creates an accent option for modules
|
json = with pkgs;
|
||||||
# the first string should be the name of the module,
|
runCommand "converted.json" { } ''
|
||||||
# followed by the local config attrset
|
${yj}/bin/yj < ${file} > $out
|
||||||
mkAccentOpt = mkBasicOpt "accent" types.accentOption;
|
'';
|
||||||
|
in
|
||||||
|
fromJSON (readFile json);
|
||||||
|
|
||||||
|
# a -> a -> [path] -> [path]
|
||||||
|
# this imports a list of paths while inheriting
|
||||||
|
# multiple attributes
|
||||||
|
mapModules = config: pkgs: extendedLib:
|
||||||
|
map (m: (import m {
|
||||||
|
inherit config pkgs;
|
||||||
|
lib = extendedLib;
|
||||||
|
}));
|
||||||
|
|
||||||
# string -> a -> a
|
# string -> a -> a
|
||||||
# this creates a basic attrset only containing an
|
# this creates a basic attrset only containing an
|
||||||
|
@ -81,7 +80,13 @@ with lib; rec {
|
||||||
# be the name of the module, followed by the local config
|
# be the name of the module, followed by the local config
|
||||||
# attrset
|
# attrset
|
||||||
mkCatppuccinOpt = name: config: {
|
mkCatppuccinOpt = name: config: {
|
||||||
enable = mkEnableOption "Catppuccin theme";
|
enable = lib.mkEnableOption "Catppuccin theme";
|
||||||
flavour = mkFlavourOpt name config;
|
flavour = mkFlavourOpt name config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# string -> a -> a
|
||||||
|
# this creates an accent option for modules
|
||||||
|
# the first string should be the name of the module,
|
||||||
|
# followed by the local config attrset
|
||||||
|
mkAccentOpt = mkBasicOpt "accent" types.accentOption;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
lib: with builtins; lib.extend (self: _: { ctp = import ./. self; })
|
lib: lib.extend (self: _: { ctp = import ./. self; })
|
||||||
|
|
|
@ -1,26 +1,30 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.boot.loader.grub.catppuccin;
|
cfg = config.boot.loader.grub.catppuccin;
|
||||||
|
enable = cfg.enable && config.boot.loader.grub.enable;
|
||||||
|
|
||||||
theme = with pkgs;
|
theme = with pkgs; let
|
||||||
let
|
src = fetchFromGitHub {
|
||||||
src = fetchFromGitHub {
|
owner = "catppuccin";
|
||||||
owner = "catppuccin";
|
repo = "grub";
|
||||||
repo = "grub";
|
rev = "803c5df0e83aba61668777bb96d90ab8f6847106";
|
||||||
rev = "803c5df0e83aba61668777bb96d90ab8f6847106";
|
sha256 = "sha256-/bSolCta8GCZ4lP0u5NVqYQ9Y3ZooYCNdTwORNvR7M0=";
|
||||||
sha256 = "sha256-/bSolCta8GCZ4lP0u5NVqYQ9Y3ZooYCNdTwORNvR7M0=";
|
};
|
||||||
};
|
in
|
||||||
in
|
runCommand "catppuccin-grub-theme" { } ''
|
||||||
runCommand "catppuccin-grub-theme" { } ''
|
mkdir -p "$out"
|
||||||
mkdir -p "$out"
|
cp -r ${src}/src/catppuccin-${cfg.flavour}-grub-theme/* "$out"/
|
||||||
cp -r ${src}/src/catppuccin-${cfg.flavour}-grub-theme/* "$out"/
|
'';
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.boot.loader.grub.catppuccin =
|
options.boot.loader.grub.catppuccin =
|
||||||
lib.ctp.mkCatppuccinOpt "grub" config;
|
lib.ctp.mkCatppuccinOpt "grub" config;
|
||||||
|
|
||||||
config.boot.loader.grub = with lib; mkIf cfg.enable {
|
config.boot.loader.grub = lib.mkIf enable {
|
||||||
font = "${theme}/font.pf2";
|
font = "${theme}/font.pf2";
|
||||||
splashImage = "${theme}/background.png";
|
splashImage = "${theme}/background.png";
|
||||||
inherit theme;
|
inherit theme;
|
||||||
|
|
Loading…
Reference in a new issue