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
badSources = builtins.filter (source: !(isGoodSource source)) (builtins.attrValues sources);
in
if ((builtins.length badSources) == 0)
then "OK"
else throw "BAD"
if ((builtins.length badSources) == 0) then "OK" else throw "BAD"

View file

@ -3,18 +3,32 @@ let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
mkSource = spec:
assert spec ? type; let
mkSource =
spec:
assert spec ? type;
let
path =
if spec.type == "Git" then mkGitSource spec
else if spec.type == "GitRelease" then mkGitSource spec
else if spec.type == "PyPi" then mkPyPiSource spec
else if spec.type == "Channel" then mkChannelSource spec
else builtins.throw "Unknown source type ${spec.type}";
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
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
spec // { outPath = path; };
mkGitSource = { repository, revision, url ? null, hash, ... }:
mkGitSource =
{
repository,
revision,
url ? null,
hash,
...
}:
assert repository ? type;
# 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
@ -23,19 +37,23 @@ let
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else assert repository.type == "Git"; builtins.fetchGit {
url = repository.url;
rev = revision;
# hash = hash;
};
else
assert repository.type == "Git";
builtins.fetchGit {
url = repository.url;
rev = revision;
# hash = hash;
};
mkPyPiSource = { url, hash, ... }:
mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource = { url, hash, ... }:
mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
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
systems = [
"x86_64-linux"
@ -33,39 +40,62 @@
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable);
in
{
apps = forAllSystems ({ lib, pkgs, system, ... }: {
add-source = {
type = "app";
program = lib.getExe (
pkgs.runCommand "add-source"
{
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 ]}
''
);
};
apps = forAllSystems (
{
lib,
pkgs,
system,
...
}:
{
add-source = {
type = "app";
program = lib.getExe (
pkgs.runCommand "add-source"
{
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 = {
type = "app";
program = lib.getExe self.packages.${system}.site.serve;
};
});
serve = {
type = "app";
program = lib.getExe self.packages.${system}.site.serve;
};
}
);
checks = forAllSystems ({ lib, 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;
};
});
checks = forAllSystems (
{
lib,
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);
packages = forAllSystems ({ lib, pkgs, system, ... }:
packages = forAllSystems (
{
lib,
pkgs,
system,
...
}:
let
version = self.shortRev or self.dirtyShortRev or "unknown";
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
@ -101,6 +131,7 @@
};
default = packages'.site;
});
}
);
};
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,4 @@
{ config
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (config.catppuccin) sources;
cfg = config.programs.btop.catppuccin;
@ -12,13 +9,11 @@ let
theme = sources.btop + themePath;
in
{
options.programs.btop.catppuccin =
lib.ctp.mkCatppuccinOpt "btop";
options.programs.btop.catppuccin = lib.ctp.mkCatppuccinOpt "btop";
config = lib.mkIf enable
{
xdg.configFile."btop${themePath}".source = theme;
config = lib.mkIf enable {
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
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (lib) ctp;
inherit (config.catppuccin) sources;
@ -10,8 +7,7 @@ let
enable = cfg.enable && config.programs.cava.enable;
in
{
options.programs.cava.catppuccin =
lib.ctp.mkCatppuccinOpt "cava";
options.programs.cava.catppuccin = lib.ctp.mkCatppuccinOpt "cava";
config.programs.cava = lib.mkIf enable {
settings = lib.ctp.fromINIRaw (sources.cava + /themes/${cfg.flavour}.cava);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,4 @@
{ config
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (config.catppuccin) sources;
@ -14,17 +11,13 @@ let
theme = sources.k9s + "/dist/${themeFile}";
in
{
options.programs.k9s.catppuccin =
lib.ctp.mkCatppuccinOpt "k9s"
// {
transparent = lib.mkEnableOption "transparent version of flavour";
};
options.programs.k9s.catppuccin = lib.ctp.mkCatppuccinOpt "k9s" // {
transparent = lib.mkEnableOption "transparent version of flavour";
};
config =
lib.mkIf enable
{
xdg.configFile."k9s${themePath}".source = theme;
config = lib.mkIf enable {
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
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (lib) ctp;
cfg = config.programs.kitty.catppuccin;
enable = cfg.enable && config.programs.kitty.enable;
in
{
options.programs.kitty.catppuccin =
ctp.mkCatppuccinOpt "kitty";
options.programs.kitty.catppuccin = ctp.mkCatppuccinOpt "kitty";
config.programs.kitty =
lib.mkIf enable { theme = "Catppuccin-${ctp.mkUpper cfg.flavour}"; };
config.programs.kitty = lib.mkIf enable { theme = "Catppuccin-${ctp.mkUpper cfg.flavour}"; };
}

View file

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

View file

@ -1,7 +1,8 @@
{ config
, pkgs
, lib
, ...
{
config,
pkgs,
lib,
...
}:
let
inherit (config.catppuccin) sources;
@ -13,8 +14,7 @@ let
extraConfigAttrs = lib.attrsets.getAttrs [ "urgency=high" ] theme;
in
{
options.services.mako.catppuccin =
lib.ctp.mkCatppuccinOpt "mako";
options.services.mako.catppuccin = lib.ctp.mkCatppuccinOpt "mako";
# Will cause infinite recursion if config.services.mako is directly set as a whole
config.services.mako = lib.mkIf enable {
@ -22,6 +22,8 @@ in
textColor = theme.text-color;
borderColor = theme.border-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
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (config.catppuccin) sources;
cfg = config.programs.micro.catppuccin;
@ -10,8 +7,7 @@ let
themePath = "catppuccin-${cfg.flavour}.micro";
in
{
options.programs.micro.catppuccin =
lib.ctp.mkCatppuccinOpt "micro";
options.programs.micro.catppuccin = lib.ctp.mkCatppuccinOpt "micro";
config = lib.mkIf enable {
programs.micro.settings.colorscheme = lib.removeSuffix ".micro" themePath;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,17 @@
{ lib
, pkgs
, config
, ...
{
lib,
pkgs,
config,
...
}:
let
inherit (lib) mkIf ctp types mkOption versionAtLeast;
inherit (lib)
mkIf
ctp
types
mkOption
versionAtLeast
;
cfg = config.services.displayManager.sddm.catppuccin;
enable = cfg.enable && config.services.displayManager.sddm.enable;
@ -14,44 +21,48 @@ let
in
{
options.services.displayManager = ctp.mkVersionedOpts minVersion {
sddm.catppuccin =
ctp.mkCatppuccinOpt "sddm"
// {
font = mkOption {
type = types.str;
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";
};
sddm.catppuccin = ctp.mkCatppuccinOpt "sddm" // {
font = mkOption {
type = types.str;
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";
};
};
};
config = mkIf enable
{
config =
mkIf enable {
environment.systemPackages = [
(pkgs.catppuccin-sddm.override {
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
common = {
catppuccin = {
@ -17,120 +21,120 @@ let
};
# shorthand for enabling a module
enable = { enable = true; };
enable = {
enable = true;
};
in
testers.runNixOSTest {
name = "module-test";
nodes.machine = { lib, ... }: {
imports = [
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 = {
nodes.machine =
{ lib, ... }:
{
imports = [
./modules/home-manager
home-manager.nixosModules.default
./modules/nixos
common
];
xdg.enable = true;
home = {
username = "test";
stateVersion = lib.mkDefault "23.11";
boot = {
loader.grub = enable;
plymouth = enable;
};
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
// {
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 = [
./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 = ''
polybar top &
'';
};
};
};
wayland.windowManager.sway = enable;
wayland.windowManager.hyprland = enable;
wayland.windowManager.sway = enable;
wayland.windowManager.hyprland = enable;
};
};
};
testScript = _: ''
machine.start()