style: format ff4ea84

This commit is contained in:
Hammy 2024-05-21 22:53:46 +01:00 committed by GitHub
parent ff4ea84b11
commit 5e1a679604
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 590 additions and 638 deletions

View file

@ -9,6 +9,4 @@ let
# find the ones that aren't # find the ones that aren't
badSources = builtins.filter (source: !(isGoodSource source)) (builtins.attrValues sources); badSources = builtins.filter (source: !(isGoodSource source)) (builtins.attrValues sources);
in in
if ((builtins.length badSources) == 0) if ((builtins.length badSources) == 0) then "OK" else throw "BAD"
then "OK"
else throw "BAD"

View file

@ -3,18 +3,32 @@ let
data = builtins.fromJSON (builtins.readFile ./sources.json); data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version; version = data.version;
mkSource = spec: mkSource =
assert spec ? type; let spec:
assert spec ? type;
let
path = path =
if spec.type == "Git" then mkGitSource spec if spec.type == "Git" then
else if spec.type == "GitRelease" then mkGitSource spec mkGitSource spec
else if spec.type == "PyPi" then mkPyPiSource spec else if spec.type == "GitRelease" then
else if spec.type == "Channel" then mkChannelSource spec mkGitSource spec
else builtins.throw "Unknown source type ${spec.type}"; else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in in
spec // { outPath = path; }; spec // { outPath = path; };
mkGitSource = { repository, revision, url ? null, hash, ... }: mkGitSource =
{
repository,
revision,
url ? null,
hash,
...
}:
assert repository ? type; assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball # In the latter case, there we will always be an url to the tarball
@ -23,19 +37,23 @@ let
inherit url; inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes sha256 = hash; # FIXME: check nix version & use SRI hashes
}) })
else assert repository.type == "Git"; builtins.fetchGit { else
url = repository.url; assert repository.type == "Git";
rev = revision; builtins.fetchGit {
# hash = hash; url = repository.url;
}; rev = revision;
# hash = hash;
};
mkPyPiSource = { url, hash, ... }: mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl { builtins.fetchurl {
inherit url; inherit url;
sha256 = hash; sha256 = hash;
}; };
mkChannelSource = { url, hash, ... }: mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball { builtins.fetchTarball {
inherit url; inherit url;
sha256 = hash; sha256 = hash;

View file

@ -16,7 +16,14 @@
}; };
}; };
outputs = { self, nixpkgs, nixpkgs-stable, home-manager, home-manager-stable }: outputs =
{
self,
nixpkgs,
nixpkgs-stable,
home-manager,
home-manager-stable,
}:
let let
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
@ -33,39 +40,62 @@
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable); forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable);
in in
{ {
apps = forAllSystems ({ lib, pkgs, system, ... }: { apps = forAllSystems (
add-source = { {
type = "app"; lib,
program = lib.getExe ( pkgs,
pkgs.runCommand "add-source" system,
{ ...
nativeBuildInputs = [ pkgs.makeWrapper ]; }:
meta.mainProgram = "add-source"; {
} '' add-source = {
mkdir -p $out/bin type = "app";
install -Dm755 ${./add_source.sh} $out/bin/add-source program = lib.getExe (
wrapProgram $out/bin/add-source \ pkgs.runCommand "add-source"
--prefix PATH : ${ lib.makeBinPath [ pkgs.npins ]} {
'' nativeBuildInputs = [ pkgs.makeWrapper ];
); meta.mainProgram = "add-source";
}; }
''
mkdir -p $out/bin
install -Dm755 ${./add_source.sh} $out/bin/add-source
wrapProgram $out/bin/add-source \
--prefix PATH : ${lib.makeBinPath [ pkgs.npins ]}
''
);
};
serve = { serve = {
type = "app"; type = "app";
program = lib.getExe self.packages.${system}.site.serve; program = lib.getExe self.packages.${system}.site.serve;
}; };
}); }
);
checks = forAllSystems ({ lib, pkgs, system, ... }: lib.optionalAttrs pkgs.stdenv.isLinux { checks = forAllSystems (
module-test-unstable = pkgs.callPackage ../test.nix { inherit home-manager; }; {
module-test-stable = nixpkgsFor.${system}.stable.callPackage ../test.nix { lib,
home-manager = home-manager-stable; pkgs,
}; system,
}); ...
}:
lib.optionalAttrs pkgs.stdenv.isLinux {
module-test-unstable = pkgs.callPackage ../test.nix { inherit home-manager; };
module-test-stable = nixpkgsFor.${system}.stable.callPackage ../test.nix {
home-manager = home-manager-stable;
};
}
);
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
packages = forAllSystems ({ lib, pkgs, system, ... }: packages = forAllSystems (
{
lib,
pkgs,
system,
...
}:
let let
version = self.shortRev or self.dirtyShortRev or "unknown"; version = self.shortRev or self.dirtyShortRev or "unknown";
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { }; mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
@ -101,6 +131,7 @@
}; };
default = packages'.site; default = packages'.site;
}); }
);
}; };
} }

View file

@ -1,48 +1,49 @@
{ lib {
, stdenvNoCC lib,
, writeShellApplication stdenvNoCC,
, mdbook writeShellApplication,
, python3 mdbook,
}: { nixosDoc python3,
, homeManagerDoc }:
, ... { nixosDoc, homeManagerDoc, ... }@args:
}@args: stdenvNoCC.mkDerivation (
stdenvNoCC.mkDerivation (finalAttrs: args // { finalAttrs:
nativeBuildInputs = [ args
mdbook // {
]; nativeBuildInputs = [ mdbook ];
dontPatch = true; dontPatch = true;
dontConfigure = true; dontConfigure = true;
doCheck = false; doCheck = false;
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
ln -s ${nixosDoc} src/options/nixos-options.md ln -s ${nixosDoc} src/options/nixos-options.md
ln -s ${homeManagerDoc} src/options/home-manager-options.md ln -s ${homeManagerDoc} src/options/home-manager-options.md
mdbook build mdbook build
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mv book $out mv book $out
runHook postInstall runHook postInstall
''; '';
passthru = { passthru = {
serve = writeShellApplication { serve = writeShellApplication {
name = "serve"; name = "serve";
runtimeInputs = [ python3 ]; runtimeInputs = [ python3 ];
text = '' text = ''
python -m http.server --bind 127.0.0.1 --directory ${finalAttrs.finalPackage} python -m http.server --bind 127.0.0.1 --directory ${finalAttrs.finalPackage}
''; '';
};
}; };
}; }
}) )

View file

@ -1,33 +1,30 @@
{ lib { lib, nixosOptionsDoc }:
, nixosOptionsDoc { version, modules }:
, (nixosOptionsDoc {
}: { version options =
, modules builtins.removeAttrs
, (lib.evalModules {
}: modules = modules ++ [
( {
nixosOptionsDoc { options.system.nixos.release = lib.mkOption {
options = type = lib.types.str;
builtins.removeAttrs default = lib.trivial.release;
( readOnly = true;
lib.evalModules { };
modules = modules ++ [{
options.system.nixos.release = lib.mkOption {
type = lib.types.str;
default = lib.trivial.release;
readOnly = true;
};
config = { config = {
_module.check = false; _module.check = false;
}; };
}];
} }
).options [ "_module" "system" ]; ];
}).options
[
"_module"
"system"
];
transformOptions = opt: builtins.removeAttrs opt [ "declarations" ]; transformOptions = opt: builtins.removeAttrs opt [ "declarations" ];
documentType = "none"; documentType = "none";
revision = version; revision = version;
} }).optionsCommonMark
).optionsCommonMark

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (lib) ctp; inherit (lib) ctp;
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -9,8 +6,7 @@ let
enable = cfg.enable && config.programs.alacritty.enable; enable = cfg.enable && config.programs.alacritty.enable;
in in
{ {
options.programs.alacritty.catppuccin = options.programs.alacritty.catppuccin = ctp.mkCatppuccinOpt "alacritty";
ctp.mkCatppuccinOpt "alacritty";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.alacritty.settings = lib.importTOML "${sources.alacritty}/catppuccin-${cfg.flavour}.toml"; programs.alacritty.settings = lib.importTOML "${sources.alacritty}/catppuccin-${cfg.flavour}.toml";

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.bat.catppuccin; cfg = config.programs.bat.catppuccin;
@ -9,8 +6,7 @@ let
themeName = "Catppuccin ${lib.ctp.mkUpper cfg.flavour}"; themeName = "Catppuccin ${lib.ctp.mkUpper cfg.flavour}";
in in
{ {
options.programs.bat.catppuccin = options.programs.bat.catppuccin = lib.ctp.mkCatppuccinOpt "bat";
lib.ctp.mkCatppuccinOpt "bat";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.bat = { programs.bat = {

View file

@ -1,23 +1,17 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.bottom.catppuccin; cfg = config.programs.bottom.catppuccin;
enable = cfg.enable && config.programs.bottom.enable; enable = cfg.enable && config.programs.bottom.enable;
in in
{ {
options.programs.bottom.catppuccin = options.programs.bottom.catppuccin = lib.ctp.mkCatppuccinOpt "bottom";
lib.ctp.mkCatppuccinOpt "bottom";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.bottom = { programs.bottom = {
settings = builtins.fromTOML ( settings = builtins.fromTOML (builtins.readFile "${sources.bottom}/themes/${cfg.flavour}.toml");
builtins.readFile "${sources.bottom}/themes/${cfg.flavour}.toml"
);
}; };
}; };
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.btop.catppuccin; cfg = config.programs.btop.catppuccin;
@ -12,13 +9,11 @@ let
theme = sources.btop + themePath; theme = sources.btop + themePath;
in in
{ {
options.programs.btop.catppuccin = options.programs.btop.catppuccin = lib.ctp.mkCatppuccinOpt "btop";
lib.ctp.mkCatppuccinOpt "btop";
config = lib.mkIf enable config = lib.mkIf enable {
{ xdg.configFile."btop${themePath}".source = theme;
xdg.configFile."btop${themePath}".source = theme;
programs.btop.settings.color_theme = themeFile; programs.btop.settings.color_theme = themeFile;
}; };
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (lib) ctp; inherit (lib) ctp;
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -10,8 +7,7 @@ let
enable = cfg.enable && config.programs.cava.enable; enable = cfg.enable && config.programs.cava.enable;
in in
{ {
options.programs.cava.catppuccin = options.programs.cava.catppuccin = lib.ctp.mkCatppuccinOpt "cava";
lib.ctp.mkCatppuccinOpt "cava";
config.programs.cava = lib.mkIf enable { config.programs.cava = lib.mkIf enable {
settings = lib.ctp.fromINIRaw (sources.cava + /themes/${cfg.flavour}.cava); settings = lib.ctp.fromINIRaw (sources.cava + /themes/${cfg.flavour}.cava);

View file

@ -1,23 +1,15 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.git.delta.catppuccin; cfg = config.programs.git.delta.catppuccin;
enable = cfg.enable && config.programs.git.delta.enable; enable = cfg.enable && config.programs.git.delta.enable;
in in
{ {
options.programs.git.delta.catppuccin = options.programs.git.delta.catppuccin = lib.ctp.mkCatppuccinOpt "catppuccin";
lib.ctp.mkCatppuccinOpt "catppuccin";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.git = { programs.git = {
includes = [ includes = [ { path = "${sources.delta}/catppuccin.gitconfig"; } ];
{
path = "${sources.delta}/catppuccin.gitconfig";
}
];
delta.options.features = "catppuccin-${cfg.flavour}"; delta.options.features = "catppuccin-${cfg.flavour}";
}; };
}; };

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -9,8 +6,7 @@ let
enable = cfg.enable && config.services.dunst.enable; enable = cfg.enable && config.services.dunst.enable;
in in
{ {
options.services.dunst.catppuccin = options.services.dunst.catppuccin = lib.ctp.mkCatppuccinOpt "dunst";
lib.ctp.mkCatppuccinOpt "dunst";
config.services.dunst = lib.mkIf enable { config.services.dunst = lib.mkIf enable {
settings = lib.ctp.fromINI (sources.dunst + /themes/${cfg.flavour}.conf); settings = lib.ctp.fromINI (sources.dunst + /themes/${cfg.flavour}.conf);

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.i18n.inputMethod.fcitx5.catppuccin; cfg = config.i18n.inputMethod.fcitx5.catppuccin;

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.fish.catppuccin; cfg = config.programs.fish.catppuccin;

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -10,27 +7,26 @@ let
palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavour}.colors; palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavour}.colors;
in in
{ {
options.programs.fzf.catppuccin = options.programs.fzf.catppuccin = lib.ctp.mkCatppuccinOpt "fzf";
lib.ctp.mkCatppuccinOpt "fzf";
config.programs.fzf.colors = lib.mkIf enable config.programs.fzf.colors =
# Manually populate with colors from catppuccin/fzf lib.mkIf enable
# The ordering is meant to match the order of catppuccin/fzf to make comparison easier # Manually populate with colors from catppuccin/fzf
(lib.attrsets.mapAttrs (_: color: palette.${color}.hex) # The ordering is meant to match the order of catppuccin/fzf to make comparison easier
{ (
"bg+" = "surface0"; lib.attrsets.mapAttrs (_: color: palette.${color}.hex) {
bg = "base"; "bg+" = "surface0";
spinner = "rosewater"; bg = "base";
hl = "red"; spinner = "rosewater";
fg = "text"; hl = "red";
header = "red"; fg = "text";
info = "mauve"; header = "red";
pointer = "rosewater"; info = "mauve";
marker = "rosewater"; pointer = "rosewater";
"fg+" = "text"; marker = "rosewater";
prompt = "mauve"; "fg+" = "text";
"hl+" = "red"; prompt = "mauve";
} "hl+" = "red";
); }
);
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.gh-dash.catppuccin; cfg = config.programs.gh-dash.catppuccin;

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -9,8 +6,7 @@ let
enable = cfg.enable && config.programs.gitui.enable; enable = cfg.enable && config.programs.gitui.enable;
in in
{ {
options.programs.gitui.catppuccin = options.programs.gitui.catppuccin = lib.ctp.mkCatppuccinOpt "gitui";
lib.ctp.mkCatppuccinOpt "gitui";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.gitui.theme = builtins.path { programs.gitui.theme = builtins.path {

View file

@ -1,15 +1,11 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.glamour.catppuccin; cfg = config.programs.glamour.catppuccin;
inherit (cfg) enable; inherit (cfg) enable;
in in
{ {
options.programs.glamour.catppuccin = options.programs.glamour.catppuccin = lib.ctp.mkCatppuccinOpt "glamour";
lib.ctp.mkCatppuccinOpt "glamour";
config = { config = {
home.sessionVariables = lib.mkIf enable { home.sessionVariables = lib.mkIf enable {

View file

@ -1,4 +1,5 @@
{ lib, defaultSources, ... }: { { lib, defaultSources, ... }:
{
options.catppuccin = { options.catppuccin = {
enable = lib.mkEnableOption "Catppuccin globally"; enable = lib.mkEnableOption "Catppuccin globally";

View file

@ -1,42 +1,58 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: }:
let let
inherit (lib) ctp mkOption mkEnableOption types; inherit (lib)
ctp
mkOption
mkEnableOption
types
;
cfg = config.gtk.catppuccin; cfg = config.gtk.catppuccin;
enable = cfg.enable && config.gtk.enable; enable = cfg.enable && config.gtk.enable;
# "dark" and "light" can be used alongside the regular accents # "dark" and "light" can be used alongside the regular accents
cursorAccentType = ctp.mergeEnums ctp.types.accentOption (lib.types.enum [ "dark" "light" ]); cursorAccentType = ctp.mergeEnums ctp.types.accentOption (
lib.types.enum [
"dark"
"light"
]
);
in in
{ {
options.gtk.catppuccin = options.gtk.catppuccin = ctp.mkCatppuccinOpt "gtk" // {
ctp.mkCatppuccinOpt "gtk" accent = ctp.mkAccentOpt "gtk";
// { size = mkOption {
accent = ctp.mkAccentOpt "gtk"; type = types.enum [
size = mkOption { "standard"
type = types.enum [ "standard" "compact" ]; "compact"
default = "standard"; ];
description = "Catppuccin size variant for gtk"; default = "standard";
}; description = "Catppuccin size variant for gtk";
tweaks = mkOption {
type = types.listOf (types.enum [ "black" "rimless" "normal" ]);
default = [ "normal" ];
description = "Catppuccin tweaks for gtk";
};
gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";
cursor = ctp.mkCatppuccinOpt "gtk cursors"
// {
accent = ctp.mkBasicOpt "accent" cursorAccentType "gtk cursors";
};
icon = ctp.mkCatppuccinOpt "gtk modified Papirus icon theme"
// {
accent = ctp.mkAccentOpt "gtk modified Papirus icon theme";
};
}; };
tweaks = mkOption {
type = types.listOf (
types.enum [
"black"
"rimless"
"normal"
]
);
default = [ "normal" ];
description = "Catppuccin tweaks for gtk";
};
gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";
cursor = ctp.mkCatppuccinOpt "gtk cursors" // {
accent = ctp.mkBasicOpt "accent" cursorAccentType "gtk cursors";
};
icon = ctp.mkCatppuccinOpt "gtk modified Papirus icon theme" // {
accent = ctp.mkAccentOpt "gtk modified Papirus icon theme";
};
};
config = lib.mkIf enable { config = lib.mkIf enable {
gtk = { gtk = {
@ -47,10 +63,7 @@ in
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 = gtkTheme = if cfg.flavour == "latte" then "Light" else "Dark";
if cfg.flavour == "latte"
then "Light"
else "Dark";
in in
{ {
name = "Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}"; name = "Catppuccin-${flavourUpper}-${sizeUpper}-${accentUpper}-${gtkTheme}";
@ -74,10 +87,7 @@ in
iconTheme = iconTheme =
let let
# use the light icon theme for latte # use the light icon theme for latte
polarity = polarity = if cfg.icon.flavour == "latte" then "Light" else "Dark";
if cfg.icon.flavour == "latte"
then "Light"
else "Dark";
in in
lib.mkIf cfg.icon.enable { lib.mkIf cfg.icon.enable {
name = "Papirus-${polarity}"; name = "Papirus-${polarity}";
@ -103,18 +113,13 @@ in
dconf.settings = lib.mkIf cfg.gnomeShellTheme { dconf.settings = lib.mkIf cfg.gnomeShellTheme {
"org/gnome/shell" = { "org/gnome/shell" = {
disable-user-extensions = false; disable-user-extensions = false;
enabled-extensions = [ enabled-extensions = [ "user-theme@gnome-shell-extensions.gcampax.github.com" ];
"user-theme@gnome-shell-extensions.gcampax.github.com"
];
}; };
"org/gnome/shell/extensions/user-theme" = { "org/gnome/shell/extensions/user-theme" = {
inherit (config.gtk.theme) name; inherit (config.gtk.theme) name;
}; };
"org/gnome/desktop/interface" = { "org/gnome/desktop/interface" = {
color-scheme = color-scheme = if cfg.flavour == "latte" then "default" else "prefer-dark";
if cfg.flavour == "latte"
then "default"
else "prefer-dark";
}; };
}; };
}; };

View file

@ -1,14 +1,12 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.helix.catppuccin; cfg = config.programs.helix.catppuccin;
enable = cfg.enable && config.programs.helix.enable; enable = cfg.enable && config.programs.helix.enable;
in in
{ {
options.programs.helix.catppuccin = with lib; options.programs.helix.catppuccin =
with lib;
ctp.mkCatppuccinOpt "helix" ctp.mkCatppuccinOpt "helix"
// { // {
useItalics = mkEnableOption "Italics in Catppuccin theme for Helix"; useItalics = mkEnableOption "Italics in Catppuccin theme for Helix";
@ -16,10 +14,7 @@ in
config.programs.helix = config.programs.helix =
let let
subdir = subdir = if cfg.useItalics then "default" else "no_italics";
if cfg.useItalics
then "default"
else "no_italics";
in in
lib.mkIf enable { lib.mkIf enable {
settings = { settings = {
@ -27,7 +22,8 @@ in
editor.color-modes = lib.mkDefault true; editor.color-modes = lib.mkDefault true;
}; };
themes."catppuccin-${cfg.flavour}" = builtins.fromTOML themes."catppuccin-${cfg.flavour}" = builtins.fromTOML (
(builtins.readFile "${sources.helix}/themes/${subdir}/catppuccin_${cfg.flavour}.toml"); builtins.readFile "${sources.helix}/themes/${subdir}/catppuccin_${cfg.flavour}.toml"
);
}; };
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.wayland.windowManager.hyprland.catppuccin; cfg = config.wayland.windowManager.hyprland.catppuccin;

View file

@ -1,16 +1,13 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.imv.catppuccin; cfg = config.programs.imv.catppuccin;
enable = cfg.enable && config.programs.imv.enable; enable = cfg.enable && config.programs.imv.enable;
in in
{ {
options.programs.imv.catppuccin = options.programs.imv.catppuccin = lib.ctp.mkCatppuccinOpt "imv";
lib.ctp.mkCatppuccinOpt "imv";
config.programs.imv.settings = lib.mkIf enable config.programs.imv.settings = lib.mkIf enable (
(lib.ctp.fromINI (sources.imv + /themes/${cfg.flavour}.config)); lib.ctp.fromINI (sources.imv + /themes/${cfg.flavour}.config)
);
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -14,17 +11,13 @@ let
theme = sources.k9s + "/dist/${themeFile}"; theme = sources.k9s + "/dist/${themeFile}";
in in
{ {
options.programs.k9s.catppuccin = options.programs.k9s.catppuccin = lib.ctp.mkCatppuccinOpt "k9s" // {
lib.ctp.mkCatppuccinOpt "k9s" transparent = lib.mkEnableOption "transparent version of flavour";
// { };
transparent = lib.mkEnableOption "transparent version of flavour";
};
config = config = lib.mkIf enable {
lib.mkIf enable xdg.configFile."k9s${themePath}".source = theme;
{
xdg.configFile."k9s${themePath}".source = theme;
programs.k9s.settings.k9s.ui.skin = themeName; programs.k9s.settings.k9s.ui.skin = themeName;
}; };
} }

View file

@ -1,16 +1,11 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (lib) ctp; inherit (lib) ctp;
cfg = config.programs.kitty.catppuccin; cfg = config.programs.kitty.catppuccin;
enable = cfg.enable && config.programs.kitty.enable; enable = cfg.enable && config.programs.kitty.enable;
in in
{ {
options.programs.kitty.catppuccin = options.programs.kitty.catppuccin = ctp.mkCatppuccinOpt "kitty";
ctp.mkCatppuccinOpt "kitty";
config.programs.kitty = config.programs.kitty = lib.mkIf enable { theme = "Catppuccin-${ctp.mkUpper cfg.flavour}"; };
lib.mkIf enable { theme = "Catppuccin-${ctp.mkUpper cfg.flavour}"; };
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (lib) ctp; inherit (lib) ctp;
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -11,11 +8,9 @@ let
themePath = "/${cfg.flavour}/${cfg.accent}.yml"; themePath = "/${cfg.flavour}/${cfg.accent}.yml";
in in
{ {
options.programs.lazygit.catppuccin = options.programs.lazygit.catppuccin = lib.ctp.mkCatppuccinOpt "lazygit" // {
lib.ctp.mkCatppuccinOpt "lazygit" // { accent = ctp.mkAccentOpt "lazygit";
accent = ctp.mkAccentOpt "lazygit"; };
};
config = lib.mkIf enable { config = lib.mkIf enable {

View file

@ -1,7 +1,8 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: }:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -13,8 +14,7 @@ let
extraConfigAttrs = lib.attrsets.getAttrs [ "urgency=high" ] theme; extraConfigAttrs = lib.attrsets.getAttrs [ "urgency=high" ] theme;
in in
{ {
options.services.mako.catppuccin = options.services.mako.catppuccin = lib.ctp.mkCatppuccinOpt "mako";
lib.ctp.mkCatppuccinOpt "mako";
# Will cause infinite recursion if config.services.mako is directly set as a whole # Will cause infinite recursion if config.services.mako is directly set as a whole
config.services.mako = lib.mkIf enable { config.services.mako = lib.mkIf enable {
@ -22,6 +22,8 @@ in
textColor = theme.text-color; textColor = theme.text-color;
borderColor = theme.border-color; borderColor = theme.border-color;
progressColor = theme.progress-color; progressColor = theme.progress-color;
extraConfig = builtins.readFile ((pkgs.formats.ini { }).generate "mako-extra-config" extraConfigAttrs); extraConfig = builtins.readFile (
(pkgs.formats.ini { }).generate "mako-extra-config" extraConfigAttrs
);
}; };
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.micro.catppuccin; cfg = config.programs.micro.catppuccin;
@ -10,8 +7,7 @@ let
themePath = "catppuccin-${cfg.flavour}.micro"; themePath = "catppuccin-${cfg.flavour}.micro";
in in
{ {
options.programs.micro.catppuccin = options.programs.micro.catppuccin = lib.ctp.mkCatppuccinOpt "micro";
lib.ctp.mkCatppuccinOpt "micro";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath; programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath;

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.mpv.catppuccin; cfg = config.programs.mpv.catppuccin;
@ -9,10 +6,9 @@ let
themeDir = sources.mpv + /themes/${cfg.flavour}/${cfg.accent}; themeDir = sources.mpv + /themes/${cfg.flavour}/${cfg.accent};
in in
{ {
options.programs.mpv.catppuccin = options.programs.mpv.catppuccin = lib.ctp.mkCatppuccinOpt "mpv" // {
lib.ctp.mkCatppuccinOpt "mpv" // { accent = lib.ctp.mkAccentOpt "mpv";
accent = lib.ctp.mkAccentOpt "mpv"; };
};
# Note that the theme is defined across multiple files # Note that the theme is defined across multiple files
config.programs.mpv = lib.mkIf enable { config.programs.mpv = lib.mkIf enable {

View file

@ -1,7 +1,8 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: }:
let let
cfg = config.programs.neovim.catppuccin; cfg = config.programs.neovim.catppuccin;

View file

@ -1,16 +1,13 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.services.polybar.catppuccin; cfg = config.services.polybar.catppuccin;
enable = cfg.enable && config.services.polybar.enable; enable = cfg.enable && config.services.polybar.enable;
in in
{ {
options.services.polybar.catppuccin = options.services.polybar.catppuccin = lib.ctp.mkCatppuccinOpt "polybar";
lib.ctp.mkCatppuccinOpt "polybar";
config.services.polybar.extraConfig = lib.mkIf enable config.services.polybar.extraConfig = lib.mkIf enable (
(builtins.readFile "${sources.polybar}/themes/${cfg.flavour}.ini"); builtins.readFile "${sources.polybar}/themes/${cfg.flavour}.ini"
);
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (lib) ctp; inherit (lib) ctp;
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -10,8 +7,7 @@ let
enable = cfg.enable && config.programs.rio.enable; enable = cfg.enable && config.programs.rio.enable;
in in
{ {
options.programs.rio.catppuccin = options.programs.rio.catppuccin = ctp.mkCatppuccinOpt "rio";
ctp.mkCatppuccinOpt "rio";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.rio.settings = lib.importTOML "${sources.rio}/catppuccin-${cfg.flavour}.toml"; programs.rio.settings = lib.importTOML "${sources.rio}/catppuccin-${cfg.flavour}.toml";

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -9,8 +6,7 @@ let
enable = cfg.enable && config.programs.rofi.enable; enable = cfg.enable && config.programs.rofi.enable;
in in
{ {
options.programs.rofi.catppuccin = options.programs.rofi.catppuccin = lib.ctp.mkCatppuccinOpt "rofi";
lib.ctp.mkCatppuccinOpt "rofi";
config.programs.rofi = lib.mkIf enable { config.programs.rofi = lib.mkIf enable {
theme = { theme = {

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.skim.catppuccin; cfg = config.programs.skim.catppuccin;

View file

@ -1,21 +1,17 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.starship.catppuccin; cfg = config.programs.starship.catppuccin;
enable = cfg.enable && config.programs.starship.enable; enable = cfg.enable && config.programs.starship.enable;
in in
{ {
options.programs.starship.catppuccin = options.programs.starship.catppuccin = lib.ctp.mkCatppuccinOpt "starship";
lib.ctp.mkCatppuccinOpt "starship";
config.programs.starship.settings = config.programs.starship.settings = lib.mkIf enable (
lib.mkIf enable {
({ format = lib.mkDefault "$all";
format = lib.mkDefault "$all"; palette = "catppuccin_${cfg.flavour}";
palette = "catppuccin_${cfg.flavour}"; }
} // builtins.fromTOML (builtins.readFile "${sources.starship}/palettes/${cfg.flavour}.toml")
// builtins.fromTOML (builtins.readFile "${sources.starship}/palettes/${cfg.flavour}.toml")); );
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.wayland.windowManager.sway.catppuccin; cfg = config.wayland.windowManager.sway.catppuccin;
@ -9,11 +6,9 @@ let
theme = "${sources.sway}/themes/catppuccin-${cfg.flavour}"; theme = "${sources.sway}/themes/catppuccin-${cfg.flavour}";
in in
{ {
options.wayland.windowManager.sway.catppuccin = options.wayland.windowManager.sway.catppuccin = lib.ctp.mkCatppuccinOpt "sway";
lib.ctp.mkCatppuccinOpt "sway";
config.wayland.windowManager.sway.extraConfigEarly = config.wayland.windowManager.sway.extraConfigEarly = lib.mkIf enable ''
lib.mkIf enable '' include ${theme}
include ${theme} '';
'';
} }

View file

@ -1,16 +1,13 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.swaylock.catppuccin; cfg = config.programs.swaylock.catppuccin;
enable = cfg.enable && config.programs.swaylock.enable; enable = cfg.enable && config.programs.swaylock.enable;
in in
{ {
options.programs.swaylock.catppuccin = options.programs.swaylock.catppuccin = lib.ctp.mkCatppuccinOpt "swaylock";
lib.ctp.mkCatppuccinOpt "swaylock";
config.programs.swaylock.settings = lib.mkIf enable config.programs.swaylock.settings = lib.mkIf enable (
(lib.ctp.fromINI (sources.swaylock + /themes/${cfg.flavour}.conf)); lib.ctp.fromINI (sources.swaylock + /themes/${cfg.flavour}.conf)
);
} }

View file

@ -1,10 +1,16 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
}: }:
let let
inherit (lib) ctp mkOption types concatStrings; inherit (lib)
ctp
mkOption
types
concatStrings
;
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.tmux.catppuccin; cfg = config.programs.tmux.catppuccin;
enable = cfg.enable && config.programs.tmux.enable; enable = cfg.enable && config.programs.tmux.enable;
@ -18,18 +24,16 @@ let
}; };
in in
{ {
options.programs.tmux.catppuccin = options.programs.tmux.catppuccin = ctp.mkCatppuccinOpt "tmux" // {
ctp.mkCatppuccinOpt "tmux" extraConfig = mkOption {
// { type = types.lines;
extraConfig = mkOption { description = "Additional configuration for the catppuccin plugin.";
type = types.lines; default = "";
description = "Additional configuration for the catppuccin plugin."; example = ''
default = ""; set -g @catppuccin_status_modules_right "application session user host date_time"
example = '' '';
set -g @catppuccin_status_modules_right "application session user host date_time"
'';
};
}; };
};
config.programs.tmux.plugins = lib.mkIf enable [ config.programs.tmux.plugins = lib.mkIf enable [
{ {

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.tofi.catppuccin; cfg = config.programs.tofi.catppuccin;

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.programs.waybar.catppuccin; cfg = config.programs.waybar.catppuccin;
@ -32,9 +29,7 @@ in
@import "${styleFile}"; @import "${styleFile}";
''; '';
}) })
(lib.mkIf (cfg.mode == "createLink") { (lib.mkIf (cfg.mode == "createLink") { xdg.configFile."waybar/catppuccin.css".source = styleFile; })
xdg.configFile."waybar/catppuccin.css".source = styleFile;
})
] ]
); );
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -9,8 +6,7 @@ let
enable = cfg.enable && config.programs.yazi.enable; enable = cfg.enable && config.programs.yazi.enable;
in in
{ {
options.programs.yazi.catppuccin = options.programs.yazi.catppuccin = lib.ctp.mkCatppuccinOpt "yazi";
lib.ctp.mkCatppuccinOpt "yazi";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.yazi.theme = lib.importTOML "${sources.yazi}/themes/${cfg.flavour}.toml"; programs.yazi.theme = lib.importTOML "${sources.yazi}/themes/${cfg.flavour}.toml";

View file

@ -1,7 +1,8 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: }:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -10,12 +11,13 @@ let
themeFile = sources.zathura + /src/catppuccin-${cfg.flavour}; themeFile = sources.zathura + /src/catppuccin-${cfg.flavour};
in in
{ {
options.programs.zathura.catppuccin = options.programs.zathura.catppuccin = lib.ctp.mkCatppuccinOpt "zathura";
lib.ctp.mkCatppuccinOpt "zathura";
config.programs.zathura.options = lib.mkIf enable config.programs.zathura.options = lib.mkIf enable (
(lib.ctp.fromINI lib.ctp.fromINI (
(pkgs.runCommand "catppuccin-zathura-theme" { } '' pkgs.runCommand "catppuccin-zathura-theme" { } ''
${pkgs.gawk}/bin/awk '/.+/ { printf "%s=%s\n", $2, $3 }' ${themeFile} > $out ${pkgs.gawk}/bin/awk '/.+/ { printf "%s=%s\n", $2, $3 }' ${themeFile} > $out
'')); ''
)
);
} }

View file

@ -1,17 +1,15 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
cfg = config.programs.zellij.catppuccin; cfg = config.programs.zellij.catppuccin;
enable = cfg.enable && config.programs.zellij.enable; enable = cfg.enable && config.programs.zellij.enable;
themeName = "catppuccin-${cfg.flavour}"; themeName = "catppuccin-${cfg.flavour}";
in in
{ {
options.programs.zellij.catppuccin = options.programs.zellij.catppuccin = lib.ctp.mkCatppuccinOpt "zellij";
lib.ctp.mkCatppuccinOpt "zellij";
config = lib.mkIf enable { config = lib.mkIf enable {
programs.zellij.settings = { theme = themeName; }; programs.zellij.settings = {
theme = themeName;
};
}; };
} }

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
inherit (lib) ctp; inherit (lib) ctp;
@ -9,8 +6,7 @@ let
enable = cfg.enable && config.programs.zsh.syntaxHighlighting.enable; enable = cfg.enable && config.programs.zsh.syntaxHighlighting.enable;
in in
{ {
options.programs.zsh.syntaxHighlighting.catppuccin = options.programs.zsh.syntaxHighlighting.catppuccin = ctp.mkCatppuccinOpt "zsh syntax highlighting";
ctp.mkCatppuccinOpt "zsh syntax highlighting";
config.programs.zsh = lib.mkIf enable { config.programs.zsh = lib.mkIf enable {
initExtra = lib.mkBefore '' initExtra = lib.mkBefore ''

View file

@ -1,7 +1,8 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
}: }:
let let
# this is a recursive attribute with all the functions below # this is a recursive attribute with all the functions below
@ -14,7 +15,8 @@ in
# a string (the name of the property, i.e., flavour # a string (the name of the property, i.e., flavour
# or accent), the type of the property, the name of # or accent), the type of the property, the name of
# the module, followed by local config attrset # the module, followed by local config attrset
mkBasicOpt = attr: type: name: mkBasicOpt =
attr: type: name:
lib.mkOption { lib.mkOption {
inherit type; inherit type;
default = config.catppuccin.${attr}; default = config.catppuccin.${attr};
@ -28,7 +30,12 @@ in
mkFlavourOpt = ctp.mkBasicOpt "flavour" ctp.types.flavourOption; mkFlavourOpt = ctp.mkBasicOpt "flavour" ctp.types.flavourOption;
types = { types = {
flavourOption = lib.types.enum [ "latte" "frappe" "macchiato" "mocha" ]; flavourOption = lib.types.enum [
"latte"
"frappe"
"macchiato"
"mocha"
];
accentOption = lib.types.enum [ accentOption = lib.types.enum [
"blue" "blue"
"flamingo" "flamingo"
@ -51,13 +58,15 @@ in
# this capitalizes the first letter in a string, # this capitalizes the first letter in a string,
# which is sometimes needed in order to format # which is sometimes needed in order to format
# the names of themes correctly # the names of themes correctly
mkUpper = str: mkUpper =
str:
(lib.toUpper (builtins.substring 0 1 str)) + (builtins.substring 1 (builtins.stringLength str) str); (lib.toUpper (builtins.substring 0 1 str)) + (builtins.substring 1 (builtins.stringLength str) str);
# a -> path -> a # a -> path -> a
# fromJSON but for yaml (and without readFile) # fromJSON but for yaml (and without readFile)
# a should be the local pkgs attrset # a should be the local pkgs attrset
fromYaml = file: fromYaml =
file:
let let
# convert to json # convert to json
json = pkgs.runCommand "converted.json" { } '' json = pkgs.runCommand "converted.json" { } ''
@ -69,7 +78,8 @@ in
# a -> path -> a # a -> path -> a
# fromJSON but for ini (and without readFile) # fromJSON but for ini (and without readFile)
# a should be the local pkgs attrset # a should be the local pkgs attrset
fromINI = file: fromINI =
file:
let let
# convert to json # convert to json
json = pkgs.runCommand "converted.json" { } '' json = pkgs.runCommand "converted.json" { } ''
@ -81,12 +91,14 @@ in
# a -> path -> a # a -> path -> a
# fromJSON but for raw ini (and without readFile) # fromJSON but for raw ini (and without readFile)
# a should be the local pkgs attrset # a should be the local pkgs attrset
fromINIRaw = file: fromINIRaw =
file:
let let
inherit (builtins) fromJSON readFile; inherit (builtins) fromJSON readFile;
# convert to json # convert to json
json = with pkgs; json =
with pkgs;
runCommand "converted.json" { } '' runCommand "converted.json" { } ''
${jc}/bin/jc --ini -r < ${file} > $out ${jc}/bin/jc --ini -r < ${file} > $out
''; '';
@ -120,11 +132,17 @@ in
# string # string
# returns the current release version of nixos or home-manager. throws an evaluation error if neither are # returns the current release version of nixos or home-manager. throws an evaluation error if neither are
# found # found
getModuleRelease = config.home.version.release or config.system.nixos.release or (throw "Couldn't determine release version!"); getModuleRelease =
config.home.version.release or config.system.nixos.release
or (throw "Couldn't determine release version!");
# string -> a -> a # string -> a -> a
# if the current module release is less than `minVersion`, all options are made no-ops with # if the current module release is less than `minVersion`, all options are made no-ops with
# `lib.mkSinkUndeclaredOptions` # `lib.mkSinkUndeclaredOptions`
mkVersionedOpts = minVersion: option: mkVersionedOpts =
if lib.versionAtLeast ctp.getModuleRelease minVersion then option else lib.mkSinkUndeclaredOptions { }; minVersion: option:
if lib.versionAtLeast ctp.getModuleRelease minVersion then
option
else
lib.mkSinkUndeclaredOptions { };
} }

View file

@ -5,13 +5,16 @@ dir:
let let
# instead of letting `evalModules` pass arguments to each file # instead of letting `evalModules` pass arguments to each file
# in our list, we import them directly # in our list, we import them directly
applyImports = file: _: import "${dir}/${file}" (args // { applyImports =
lib = lib.extend (final: _: { file: _:
ctp = import ./. (args // { lib = final; }); import "${dir}/${file}" (
}); args
// {
lib = lib.extend (final: _: { ctp = import ./. (args // { lib = final; }); });
defaultSources = import ../../.sources; defaultSources = import ../../.sources;
}); }
);
in in
lib.pipe dir [ lib.pipe dir [
builtins.readDir builtins.readDir

View file

@ -1,7 +1,4 @@
{ config { config, lib, ... }:
, lib
, ...
}:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
cfg = config.console.catppuccin; cfg = config.console.catppuccin;
@ -9,8 +6,7 @@ let
palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavour}.colors; palette = (lib.importJSON "${sources.palette}/palette.json").${cfg.flavour}.colors;
in in
{ {
options.console.catppuccin = options.console.catppuccin = lib.ctp.mkCatppuccinOpt "console";
lib.ctp.mkCatppuccinOpt "console";
config.console.colors = lib.mkIf enable ( config.console.colors = lib.mkIf enable (
# Manually populate with colors from catppuccin/tty # Manually populate with colors from catppuccin/tty

View file

@ -1,4 +1,5 @@
{ lib, defaultSources, ... }: { { lib, defaultSources, ... }:
{
options.catppuccin = { options.catppuccin = {
enable = lib.mkEnableOption "Catppuccin globally"; enable = lib.mkEnableOption "Catppuccin globally";

View file

@ -1,7 +1,8 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
}: }:
let let
inherit (config.catppuccin) sources; inherit (config.catppuccin) sources;
@ -15,8 +16,7 @@ let
''; '';
in in
{ {
options.boot.loader.grub.catppuccin = options.boot.loader.grub.catppuccin = lib.ctp.mkCatppuccinOpt "grub";
lib.ctp.mkCatppuccinOpt "grub";
config.boot.loader.grub = lib.mkIf enable { config.boot.loader.grub = lib.mkIf enable {
font = "${theme}/font.pf2"; font = "${theme}/font.pf2";

View file

@ -1,7 +1,8 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: }:
let let
inherit (lib) ctp mkIf; inherit (lib) ctp mkIf;
@ -13,10 +14,6 @@ in
config.boot.plymouth = mkIf enable { config.boot.plymouth = mkIf enable {
theme = "catppuccin-${cfg.flavour}"; theme = "catppuccin-${cfg.flavour}";
themePackages = [ themePackages = [ (pkgs.catppuccin-plymouth.override { variant = cfg.flavour; }) ];
(pkgs.catppuccin-plymouth.override {
variant = cfg.flavour;
})
];
}; };
} }

View file

@ -1,10 +1,17 @@
{ lib {
, pkgs lib,
, config pkgs,
, ... config,
...
}: }:
let let
inherit (lib) mkIf ctp types mkOption versionAtLeast; inherit (lib)
mkIf
ctp
types
mkOption
versionAtLeast
;
cfg = config.services.displayManager.sddm.catppuccin; cfg = config.services.displayManager.sddm.catppuccin;
enable = cfg.enable && config.services.displayManager.sddm.enable; enable = cfg.enable && config.services.displayManager.sddm.enable;
@ -14,44 +21,48 @@ let
in in
{ {
options.services.displayManager = ctp.mkVersionedOpts minVersion { options.services.displayManager = ctp.mkVersionedOpts minVersion {
sddm.catppuccin = sddm.catppuccin = ctp.mkCatppuccinOpt "sddm" // {
ctp.mkCatppuccinOpt "sddm" font = mkOption {
// { type = types.str;
font = mkOption { default = "Noto Sans";
type = types.str; description = "Font to use for the login screen";
default = "Noto Sans";
description = "Font to use for the login screen";
};
fontSize = mkOption {
type = types.str;
default = "9";
description = "Font size to use for the login screen";
};
background = mkOption {
type = with types; (either path str);
default = "";
description = "Background image to use for the login screen";
};
loginBackground = mkOption {
type = types.bool;
default = true;
description = "Add an additional background layer to the login panel";
};
}; };
fontSize = mkOption {
type = types.str;
default = "9";
description = "Font size to use for the login screen";
};
background = mkOption {
type = with types; (either path str);
default = "";
description = "Background image to use for the login screen";
};
loginBackground = mkOption {
type = types.bool;
default = true;
description = "Add an additional background layer to the login panel";
};
};
}; };
config = mkIf enable config =
{ mkIf enable {
environment.systemPackages = [ environment.systemPackages = [
(pkgs.catppuccin-sddm.override { (pkgs.catppuccin-sddm.override {
flavor = cfg.flavour; flavor = cfg.flavour;
inherit (cfg) font fontSize background loginBackground; inherit (cfg)
font
fontSize
background
loginBackground
;
}) })
]; ];
} // mkIf (enable && versionAtLeast ctp.getModuleRelease minVersion) { }
services.displayManager.sddm.theme = "catppuccin-${cfg.flavour}"; // mkIf (enable && versionAtLeast ctp.getModuleRelease minVersion) {
}; services.displayManager.sddm.theme = "catppuccin-${cfg.flavour}";
};
} }

200
test.nix
View file

@ -1,4 +1,8 @@
{ testers, fetchFromGitHub, home-manager }: {
testers,
fetchFromGitHub,
home-manager,
}:
let let
common = { common = {
catppuccin = { catppuccin = {
@ -17,120 +21,120 @@ let
}; };
# shorthand for enabling a module # shorthand for enabling a module
enable = { enable = true; }; enable = {
enable = true;
};
in in
testers.runNixOSTest { testers.runNixOSTest {
name = "module-test"; name = "module-test";
nodes.machine = { lib, ... }: { nodes.machine =
imports = [ { lib, ... }:
home-manager.nixosModules.default {
./modules/nixos
common
];
boot = {
loader.grub = enable;
plymouth = enable;
};
services = {
displayManager.sddm = enable;
xserver.enable = true; # required for sddm
};
console = enable;
programs.dconf = enable; # required for gtk
users.users.test = {
isNormalUser = true;
home = "/home/test";
};
virtualisation = {
memorySize = 4096;
writableStore = true;
};
home-manager.users.test = {
imports = [ imports = [
./modules/home-manager home-manager.nixosModules.default
./modules/nixos
common common
]; ];
xdg.enable = true; boot = {
loader.grub = enable;
home = { plymouth = enable;
username = "test";
stateVersion = lib.mkDefault "23.11";
}; };
manual.manpages.enable = lib.mkDefault false;
i18n.inputMethod.enabled = "fcitx5";
programs = {
alacritty = enable;
bat = enable;
bottom = enable;
btop = enable;
cava = enable;
fish = enable;
foot = enable;
fzf = enable;
gh-dash = enable;
git =
enable
// {
delta = enable;
};
gitui = enable;
# this is enabled by default already, but still
# listing explicitly so we know it's tested
glamour.catppuccin.enable = true;
helix = enable;
imv = enable;
k9s = enable;
kitty = enable;
lazygit = enable;
micro = enable;
mpv = enable;
neovim = enable;
rio = enable;
rofi = enable;
skim = enable;
starship = enable;
swaylock = enable;
tmux = enable;
tofi = enable;
waybar = enable;
yazi = enable;
zathura = enable;
zellij = enable;
zsh = enable // {
syntaxHighlighting = enable;
};
};
gtk = lib.recursiveUpdate enable { catppuccin.cursor.enable = true; };
services = { services = {
dunst = enable; displayManager.sddm = enable;
mako = enable; xserver.enable = true; # required for sddm
polybar = };
enable
// { console = enable;
programs.dconf = enable; # required for gtk
users.users.test = {
isNormalUser = true;
home = "/home/test";
};
virtualisation = {
memorySize = 4096;
writableStore = true;
};
home-manager.users.test = {
imports = [
./modules/home-manager
common
];
xdg.enable = true;
home = {
username = "test";
stateVersion = lib.mkDefault "23.11";
};
manual.manpages.enable = lib.mkDefault false;
i18n.inputMethod.enabled = "fcitx5";
programs = {
alacritty = enable;
bat = enable;
bottom = enable;
btop = enable;
cava = enable;
fish = enable;
foot = enable;
fzf = enable;
gh-dash = enable;
git = enable // {
delta = enable;
};
gitui = enable;
# this is enabled by default already, but still
# listing explicitly so we know it's tested
glamour.catppuccin.enable = true;
helix = enable;
imv = enable;
k9s = enable;
kitty = enable;
lazygit = enable;
micro = enable;
mpv = enable;
neovim = enable;
rio = enable;
rofi = enable;
skim = enable;
starship = enable;
swaylock = enable;
tmux = enable;
tofi = enable;
waybar = enable;
yazi = enable;
zathura = enable;
zellij = enable;
zsh = enable // {
syntaxHighlighting = enable;
};
};
gtk = lib.recursiveUpdate enable { catppuccin.cursor.enable = true; };
services = {
dunst = enable;
mako = enable;
polybar = enable // {
script = '' script = ''
polybar top & polybar top &
''; '';
}; };
}; };
wayland.windowManager.sway = enable; wayland.windowManager.sway = enable;
wayland.windowManager.hyprland = enable; wayland.windowManager.hyprland = enable;
};
}; };
};
testScript = _: '' testScript = _: ''
machine.start() machine.start()