-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(modules): cleanup module importing and lib injection (#385)
* refactor(modules): share global option definitions * refactor: use mkCatppuccinOpt for all main options * refactor(modules): lib.ctp.mkCatppuccinOpt -> lib.ctp.mkCatppuccinOption Meant to be more inline with `lib.mkOption` from Nixpkgs * refactor(modules): types.{accent,flavor}Option -> types.{accent,flavor} * refactor(modules): inject custom lib with `lib.modules.importApply` A bit cleaner than our current solution, and creates a clear separation between our functions and those from Nixpkgs * refactor(modules): use standalone attrset for lib We don't need to extend nixpkgs.lib anymore * refactor(modules): remove unnecessary config guards We don't need to be doing this when the upstream modules already guard against their own `enable` option * chore(tests): remove unused arg
- Loading branch information
Showing
63 changed files
with
796 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
{ catppuccinLib }: | ||
{ config, lib, ... }: | ||
|
||
let | ||
inherit (config.catppuccin) sources; | ||
|
||
cfg = config.programs.alacritty.catppuccin; | ||
enable = cfg.enable && config.programs.alacritty.enable; | ||
in | ||
|
||
{ | ||
options.programs.alacritty.catppuccin = lib.ctp.mkCatppuccinOpt { name = "alacritty"; }; | ||
options.programs.alacritty.catppuccin = catppuccinLib.mkCatppuccinOption { name = "alacritty"; }; | ||
|
||
config = lib.mkIf enable { | ||
programs.alacritty.settings = lib.importTOML "${sources.alacritty}/catppuccin-${cfg.flavor}.toml"; | ||
config = lib.mkIf cfg.enable { | ||
programs.alacritty = { | ||
settings = lib.importTOML "${sources.alacritty}/catppuccin-${cfg.flavor}.toml"; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
./gh-dash.nix | ||
./gitui.nix | ||
./glamour.nix | ||
./globals.nix | ||
./gtk.nix | ||
./helix.nix | ||
./hyprland.nix | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
{ catppuccinLib }: | ||
{ config, lib, ... }: | ||
|
||
let | ||
inherit (config.catppuccin) sources; | ||
|
||
cfg = config.programs.btop.catppuccin; | ||
enable = cfg.enable && config.programs.btop.enable; | ||
|
||
themeFile = "catppuccin_${cfg.flavor}.theme"; | ||
themePath = "/themes/${themeFile}"; | ||
theme = sources.btop + themePath; | ||
in | ||
|
||
{ | ||
options.programs.btop.catppuccin = lib.ctp.mkCatppuccinOpt { name = "btop"; }; | ||
options.programs.btop.catppuccin = catppuccinLib.mkCatppuccinOption { name = "btop"; }; | ||
|
||
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; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
{ catppuccinLib }: | ||
{ config, lib, ... }: | ||
|
||
let | ||
inherit (config.catppuccin) sources; | ||
|
||
cfg = config.programs.cava.catppuccin; | ||
enable = cfg.enable && config.programs.cava.enable; | ||
flavor = "${cfg.flavor}" + lib.optionalString cfg.transparent "-transparent"; | ||
in | ||
|
||
{ | ||
options.programs.cava.catppuccin = lib.ctp.mkCatppuccinOpt { name = "cava"; } // { | ||
options.programs.cava.catppuccin = catppuccinLib.mkCatppuccinOption { name = "cava"; } // { | ||
transparent = lib.mkEnableOption "transparent version of flavor"; | ||
}; | ||
|
||
config.programs.cava = lib.mkIf enable { | ||
settings = lib.ctp.fromINIRaw (sources.cava + "/themes/${flavor}.cava"); | ||
config = lib.mkIf cfg.enable { | ||
programs.cava = { | ||
settings = catppuccinLib.fromINIRaw (sources.cava + "/themes/${flavor}.cava"); | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,43 @@ | ||
{ catppuccinLib }: | ||
{ | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: | ||
|
||
let | ||
inherit (lib) ctp mkIf; | ||
cfg = config.catppuccin.pointerCursor; | ||
|
||
# "dark" and "light" can be used alongside the regular accents | ||
cursorAccentType = ctp.mergeEnums ctp.types.accentOption ( | ||
cursorAccentType = catppuccinLib.mergeEnums catppuccinLib.types.accent ( | ||
lib.types.enum [ | ||
"dark" | ||
"light" | ||
] | ||
); | ||
in | ||
|
||
{ | ||
options.catppuccin.pointerCursor = | ||
ctp.mkCatppuccinOpt { | ||
catppuccinLib.mkCatppuccinOption { | ||
name = "pointer cursors"; | ||
# NOTE: we exclude this from the global `catppuccin.enable` as there is no | ||
# `enable` option in the upstream module to guard it | ||
enableDefault = false; | ||
# NOTE: We exclude this as there is no `enable` option in the upstream | ||
# module to guard it | ||
useGlobalEnable = false; | ||
} | ||
// { | ||
accent = ctp.mkBasicOpt "accent" cursorAccentType "cursors"; | ||
accent = lib.mkOption { | ||
type = cursorAccentType; | ||
default = config.catppuccin.accent; | ||
description = "Catppuccin accent for pointer cursors"; | ||
}; | ||
}; | ||
|
||
config.home.pointerCursor = mkIf cfg.enable { | ||
name = "catppuccin-${cfg.flavor}-${cfg.accent}-cursors"; | ||
package = pkgs.catppuccin-cursors.${cfg.flavor + ctp.mkUpper cfg.accent}; | ||
config = lib.mkIf cfg.enable { | ||
home.pointerCursor = { | ||
name = "catppuccin-${cfg.flavor}-${cfg.accent}-cursors"; | ||
package = pkgs.catppuccin-cursors.${cfg.flavor + catppuccinLib.mkUpper cfg.accent}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
{ lib, ... }: | ||
|
||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
{ | ||
imports = import ../lib/import-modules.nix { | ||
inherit config lib pkgs; | ||
modules = import ./all-modules.nix; | ||
}; | ||
imports = [ | ||
(lib.modules.importApply ../global.nix { catppuccinModules = import ./all-modules.nix; }) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.