feat(modules): add global enable option (#124)

* feat: add `enable` option globally

* chore(modules): use catppuccin.enable in test.nix

---------

Co-authored-by: seth <getchoo@tuta.io>
This commit is contained in:
Pol Dellaiera 2024-04-22 19:39:12 +02:00 committed by GitHub
parent 29bd8a3bda
commit e45a44e26e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 64 additions and 80 deletions

View file

@ -1,20 +1,5 @@
{ {
"nodes": { "nodes": {
"get-flake": {
"locked": {
"lastModified": 1694475786,
"narHash": "sha256-s5wDmPooMUNIAAsxxCMMh9g68AueGg63DYk2hVZJbc8=",
"owner": "ursi",
"repo": "get-flake",
"rev": "ac54750e3b95dab6ec0726d77f440efe6045bec1",
"type": "github"
},
"original": {
"owner": "ursi",
"repo": "get-flake",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -52,7 +37,6 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"get-flake": "get-flake",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }

View file

@ -8,11 +8,9 @@
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
get-flake.url = "github:ursi/get-flake";
}; };
outputs = { self, nixpkgs, get-flake, ... }@inputs: outputs = { self, nixpkgs, ... }@inputs:
let let
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
@ -24,11 +22,10 @@
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s}); forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s});
ctp = get-flake ../.;
in in
{ {
checks = forAllSystems (pkgs: lib.optionalAttrs pkgs.stdenv.isLinux { checks = forAllSystems (pkgs: lib.optionalAttrs pkgs.stdenv.isLinux {
module-vm-test = pkgs.nixosTest (import ../test.nix { inherit ctp inputs; }); module-vm-test = pkgs.nixosTest (import ../test.nix inputs);
}); });
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt); formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
@ -57,8 +54,8 @@
''; '';
in in
{ {
nixos-doc = mkDoc "nixos" ctp.nixosModules.catppuccin; nixos-doc = mkDoc "nixos" ../modules/nixos;
home-manager-doc = mkDoc "home-manager" ctp.homeManagerModules.catppuccin; home-manager-doc = mkDoc "home-manager" ../modules/home-manager;
default = self.packages.${pkgs.system}.home-manager-doc; default = self.packages.${pkgs.system}.home-manager-doc;
}); });

View file

@ -1,5 +1,7 @@
{ lib, ... }: { { lib, ... }: {
options.catppuccin = { options.catppuccin = {
enable = lib.mkEnableOption "Catppuccin globally";
flavour = lib.mkOption { flavour = lib.mkOption {
type = lib.ctp.types.flavourOption; type = lib.ctp.types.flavourOption;
default = "latte"; default = "latte";

View file

@ -105,7 +105,9 @@ in
# be the name of the module, followed by the local config # be the name of the module, followed by the local config
# attrset # attrset
mkCatppuccinOpt = name: { mkCatppuccinOpt = name: {
enable = lib.mkEnableOption "Catppuccin theme"; enable = lib.mkEnableOption "Catppuccin theme" // {
default = config.catppuccin.enable;
};
flavour = mkFlavourOpt name; flavour = mkFlavourOpt name;
}; };

View file

@ -1,5 +1,7 @@
{ lib, ... }: { { lib, ... }: {
options.catppuccin = { options.catppuccin = {
enable = lib.mkEnableOption "Catppuccin globally";
flavour = lib.mkOption { flavour = lib.mkOption {
type = lib.ctp.types.flavourOption; type = lib.ctp.types.flavourOption;
default = "latte"; default = "latte";

109
test.nix
View file

@ -1,36 +1,35 @@
{ ctp inputs:
, inputs
, ...
}:
let let
common = { common = {
catppuccin.flavour = "mocha"; catppuccin = {
users.users.test = { enable = true;
isNormalUser = true; flavour = "mocha";
home = "/home/test";
}; };
}; };
ctpEnable = { # shorthand enable
enable = true; enable = { enable = true; };
catppuccin.enable = true;
};
in in
{ {
name = "module-test"; name = "module-test";
nodes.machine = { lib, ... }: { nodes.machine = { lib, ... }: {
imports = [ imports = [
ctp.nixosModules.catppuccin
inputs.home-manager.nixosModules.default inputs.home-manager.nixosModules.default
./modules/nixos
common common
]; ];
boot.loader.grub = ctpEnable; boot.loader.grub = enable;
console = ctpEnable; console = enable;
programs.dconf.enable = true; # required for gtk programs.dconf = enable; # required for gtk
users.users.test = {
isNormalUser = true;
home = "/home/test";
};
virtualisation = { virtualisation = {
memorySize = 4096; memorySize = 4096;
@ -39,11 +38,10 @@ in
home-manager.users.test = { home-manager.users.test = {
imports = [ imports = [
ctp.homeManagerModules.catppuccin ./modules/home-manager
common
]; ];
inherit (common) catppuccin;
xdg.enable = true; xdg.enable = true;
home = { home = {
@ -53,49 +51,48 @@ in
manual.manpages.enable = lib.mkDefault false; manual.manpages.enable = lib.mkDefault false;
i18n.inputMethod = { i18n.inputMethod.enabled = "fcitx5";
enabled = "fcitx5";
fcitx5.catppuccin.enable = true;
};
programs = { programs = {
alacritty = ctpEnable; alacritty = enable;
bat = ctpEnable; bat = enable;
bottom = ctpEnable; bottom = enable;
btop = ctpEnable; btop = enable;
cava = ctpEnable; cava = enable;
fish = ctpEnable; fish = enable;
foot = ctpEnable; foot = enable;
fzf = ctpEnable; fzf = enable;
git.enable = true; # Required for delta git = enable // {
git.delta = ctpEnable; delta = enable;
gitui = ctpEnable; };
gitui = enable;
# this is enabled by default already, but still
# listing explicitly so we know it's tested
glamour.catppuccin.enable = true; glamour.catppuccin.enable = true;
helix = ctpEnable; helix = enable;
home-manager.enable = false; imv = enable;
imv = ctpEnable; k9s = enable;
k9s = ctpEnable; kitty = enable;
kitty = ctpEnable; lazygit = enable;
lazygit = ctpEnable; micro = enable;
micro = ctpEnable; mpv = enable;
mpv = ctpEnable; neovim = enable;
neovim = ctpEnable; rio = enable;
rio = ctpEnable; rofi = enable;
rofi = ctpEnable; starship = enable;
starship = ctpEnable; swaylock = enable;
swaylock = ctpEnable; tmux = enable;
tmux = ctpEnable; yazi = enable;
yazi = ctpEnable; zathura = enable;
zathura = ctpEnable;
}; };
gtk = lib.recursiveUpdate ctpEnable { catppuccin.cursor.enable = true; }; gtk = lib.recursiveUpdate enable { catppuccin.cursor.enable = true; };
services = { services = {
dunst = ctpEnable; dunst = enable;
mako = ctpEnable; mako = enable;
polybar = polybar =
ctpEnable enable
// { // {
script = '' script = ''
polybar top & polybar top &
@ -103,8 +100,8 @@ in
}; };
}; };
wayland.windowManager.sway = ctpEnable; wayland.windowManager.sway = enable;
wayland.windowManager.hyprland = ctpEnable; wayland.windowManager.hyprland = enable;
}; };
}; };