From 5e1a679604b3de7bcacbfad798922b87cbc51d25 Mon Sep 17 00:00:00 2001 From: Hammy <58985301+sgoudham@users.noreply.github.com> Date: Tue, 21 May 2024 22:53:46 +0100 Subject: [PATCH] style: format ff4ea84 --- .github/checkSources.nix | 4 +- .sources/default.nix | 48 +++-- dev/flake.nix | 91 +++++--- docs/mk-site.nix | 75 +++---- docs/options-doc.nix | 55 +++-- modules/home-manager/alacritty.nix | 8 +- modules/home-manager/bat.nix | 8 +- modules/home-manager/bottom.nix | 12 +- modules/home-manager/btop.nix | 17 +- modules/home-manager/cava.nix | 8 +- modules/home-manager/delta.nix | 14 +- modules/home-manager/dunst.nix | 8 +- modules/home-manager/fcitx5.nix | 5 +- modules/home-manager/fish.nix | 5 +- modules/home-manager/foot.nix | 5 +- modules/home-manager/fzf.nix | 48 ++--- modules/home-manager/gh-dash.nix | 5 +- modules/home-manager/gitui.nix | 8 +- modules/home-manager/glamour.nix | 8 +- modules/home-manager/globals.nix | 3 +- modules/home-manager/gtk.nix | 97 +++++---- modules/home-manager/helix.nix | 18 +- modules/home-manager/hyprland.nix | 5 +- modules/home-manager/imv.nix | 13 +- modules/home-manager/k9s.nix | 23 +- modules/home-manager/kitty.nix | 11 +- modules/home-manager/lazygit.nix | 13 +- modules/home-manager/mako.nix | 16 +- modules/home-manager/micro.nix | 8 +- modules/home-manager/mpv.nix | 12 +- modules/home-manager/neovim.nix | 9 +- modules/home-manager/polybar.nix | 13 +- modules/home-manager/rio.nix | 8 +- modules/home-manager/rofi.nix | 8 +- modules/home-manager/skim.nix | 5 +- modules/home-manager/starship.nix | 22 +- modules/home-manager/sway.nix | 15 +- modules/home-manager/swaylock.nix | 13 +- modules/home-manager/tmux.nix | 36 ++-- modules/home-manager/tofi.nix | 5 +- modules/home-manager/waybar.nix | 9 +- modules/home-manager/yazi.nix | 8 +- modules/home-manager/zathura.nix | 22 +- modules/home-manager/zellij.nix | 12 +- .../home-manager/zsh-syntax-highlighting.nix | 8 +- modules/lib/default.nix | 46 ++-- modules/lib/mkImports.nix | 15 +- modules/nixos/console.nix | 8 +- modules/nixos/globals.nix | 3 +- modules/nixos/grub.nix | 12 +- modules/nixos/plymouth.nix | 15 +- modules/nixos/sddm.nix | 85 ++++---- test.nix | 200 +++++++++--------- 53 files changed, 590 insertions(+), 638 deletions(-) diff --git a/.github/checkSources.nix b/.github/checkSources.nix index 8aec317..50e51e0 100644 --- a/.github/checkSources.nix +++ b/.github/checkSources.nix @@ -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" diff --git a/.sources/default.nix b/.sources/default.nix index 4a7c372..ae29155 100644 --- a/.sources/default.nix +++ b/.sources/default.nix @@ -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; diff --git a/dev/flake.nix b/dev/flake.nix index b84bd48..f00b1d2 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -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; - }); + } + ); }; } diff --git a/docs/mk-site.nix b/docs/mk-site.nix index a888c67..312202d 100644 --- a/docs/mk-site.nix +++ b/docs/mk-site.nix @@ -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} + ''; + }; }; - }; -}) + } +) diff --git a/docs/options-doc.nix b/docs/options-doc.nix index 6bec83c..66d9d05 100644 --- a/docs/options-doc.nix +++ b/docs/options-doc.nix @@ -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 diff --git a/modules/home-manager/alacritty.nix b/modules/home-manager/alacritty.nix index 1ecef9d..cae9d2d 100644 --- a/modules/home-manager/alacritty.nix +++ b/modules/home-manager/alacritty.nix @@ -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"; diff --git a/modules/home-manager/bat.nix b/modules/home-manager/bat.nix index b583c67..5e37510 100644 --- a/modules/home-manager/bat.nix +++ b/modules/home-manager/bat.nix @@ -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 = { diff --git a/modules/home-manager/bottom.nix b/modules/home-manager/bottom.nix index 0f94aad..f32d5ea 100644 --- a/modules/home-manager/bottom.nix +++ b/modules/home-manager/bottom.nix @@ -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"); }; }; } diff --git a/modules/home-manager/btop.nix b/modules/home-manager/btop.nix index 1d67e94..fea90a3 100644 --- a/modules/home-manager/btop.nix +++ b/modules/home-manager/btop.nix @@ -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; + }; } diff --git a/modules/home-manager/cava.nix b/modules/home-manager/cava.nix index 32a2d77..34806ae 100644 --- a/modules/home-manager/cava.nix +++ b/modules/home-manager/cava.nix @@ -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); diff --git a/modules/home-manager/delta.nix b/modules/home-manager/delta.nix index 0119b05..d73c9b8 100644 --- a/modules/home-manager/delta.nix +++ b/modules/home-manager/delta.nix @@ -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}"; }; }; diff --git a/modules/home-manager/dunst.nix b/modules/home-manager/dunst.nix index ba28dda..b55818f 100644 --- a/modules/home-manager/dunst.nix +++ b/modules/home-manager/dunst.nix @@ -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); diff --git a/modules/home-manager/fcitx5.nix b/modules/home-manager/fcitx5.nix index 7fd18b7..d01c28d 100644 --- a/modules/home-manager/fcitx5.nix +++ b/modules/home-manager/fcitx5.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; cfg = config.i18n.inputMethod.fcitx5.catppuccin; diff --git a/modules/home-manager/fish.nix b/modules/home-manager/fish.nix index 262dc7a..d51c14c 100644 --- a/modules/home-manager/fish.nix +++ b/modules/home-manager/fish.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; cfg = config.programs.fish.catppuccin; diff --git a/modules/home-manager/foot.nix b/modules/home-manager/foot.nix index 444056a..ff95740 100644 --- a/modules/home-manager/foot.nix +++ b/modules/home-manager/foot.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; diff --git a/modules/home-manager/fzf.nix b/modules/home-manager/fzf.nix index 9e03c83..4807f1d 100644 --- a/modules/home-manager/fzf.nix +++ b/modules/home-manager/fzf.nix @@ -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"; + } + ); } - diff --git a/modules/home-manager/gh-dash.nix b/modules/home-manager/gh-dash.nix index dedc421..34a6983 100644 --- a/modules/home-manager/gh-dash.nix +++ b/modules/home-manager/gh-dash.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; cfg = config.programs.gh-dash.catppuccin; diff --git a/modules/home-manager/gitui.nix b/modules/home-manager/gitui.nix index 018f440..c6f25b2 100644 --- a/modules/home-manager/gitui.nix +++ b/modules/home-manager/gitui.nix @@ -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 { diff --git a/modules/home-manager/glamour.nix b/modules/home-manager/glamour.nix index 118a000..04e3f07 100644 --- a/modules/home-manager/glamour.nix +++ b/modules/home-manager/glamour.nix @@ -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 { diff --git a/modules/home-manager/globals.nix b/modules/home-manager/globals.nix index 0b627fb..0f66e18 100644 --- a/modules/home-manager/globals.nix +++ b/modules/home-manager/globals.nix @@ -1,4 +1,5 @@ -{ lib, defaultSources, ... }: { +{ lib, defaultSources, ... }: +{ options.catppuccin = { enable = lib.mkEnableOption "Catppuccin globally"; diff --git a/modules/home-manager/gtk.nix b/modules/home-manager/gtk.nix index 29c4994..a661f68 100644 --- a/modules/home-manager/gtk.nix +++ b/modules/home-manager/gtk.nix @@ -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"; }; }; }; diff --git a/modules/home-manager/helix.nix b/modules/home-manager/helix.nix index bbba731..bf4e581 100644 --- a/modules/home-manager/helix.nix +++ b/modules/home-manager/helix.nix @@ -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" + ); }; } diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index eddad4a..388167c 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; cfg = config.wayland.windowManager.hyprland.catppuccin; diff --git a/modules/home-manager/imv.nix b/modules/home-manager/imv.nix index 9ecc9b5..a4e0b78 100644 --- a/modules/home-manager/imv.nix +++ b/modules/home-manager/imv.nix @@ -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) + ); } diff --git a/modules/home-manager/k9s.nix b/modules/home-manager/k9s.nix index 4c24746..e2b6096 100644 --- a/modules/home-manager/k9s.nix +++ b/modules/home-manager/k9s.nix @@ -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; + }; } diff --git a/modules/home-manager/kitty.nix b/modules/home-manager/kitty.nix index 7e2f138..98ee9ee 100644 --- a/modules/home-manager/kitty.nix +++ b/modules/home-manager/kitty.nix @@ -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}"; }; } diff --git a/modules/home-manager/lazygit.nix b/modules/home-manager/lazygit.nix index 004578b..ba5faee 100644 --- a/modules/home-manager/lazygit.nix +++ b/modules/home-manager/lazygit.nix @@ -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 { diff --git a/modules/home-manager/mako.nix b/modules/home-manager/mako.nix index 9b1a7e9..485b98d 100644 --- a/modules/home-manager/mako.nix +++ b/modules/home-manager/mako.nix @@ -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 + ); }; } diff --git a/modules/home-manager/micro.nix b/modules/home-manager/micro.nix index eb878c1..be51f89 100644 --- a/modules/home-manager/micro.nix +++ b/modules/home-manager/micro.nix @@ -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; diff --git a/modules/home-manager/mpv.nix b/modules/home-manager/mpv.nix index 1ebb7a1..489566e 100644 --- a/modules/home-manager/mpv.nix +++ b/modules/home-manager/mpv.nix @@ -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 { diff --git a/modules/home-manager/neovim.nix b/modules/home-manager/neovim.nix index c77bd3f..d781127 100644 --- a/modules/home-manager/neovim.nix +++ b/modules/home-manager/neovim.nix @@ -1,7 +1,8 @@ -{ config -, pkgs -, lib -, ... +{ + config, + pkgs, + lib, + ... }: let cfg = config.programs.neovim.catppuccin; diff --git a/modules/home-manager/polybar.nix b/modules/home-manager/polybar.nix index 0c42c52..fd0680d 100644 --- a/modules/home-manager/polybar.nix +++ b/modules/home-manager/polybar.nix @@ -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" + ); } diff --git a/modules/home-manager/rio.nix b/modules/home-manager/rio.nix index a090353..64b043a 100644 --- a/modules/home-manager/rio.nix +++ b/modules/home-manager/rio.nix @@ -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"; diff --git a/modules/home-manager/rofi.nix b/modules/home-manager/rofi.nix index 5afd12a..c1f1ae0 100644 --- a/modules/home-manager/rofi.nix +++ b/modules/home-manager/rofi.nix @@ -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 = { diff --git a/modules/home-manager/skim.nix b/modules/home-manager/skim.nix index 5690dde..6d25038 100644 --- a/modules/home-manager/skim.nix +++ b/modules/home-manager/skim.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; cfg = config.programs.skim.catppuccin; diff --git a/modules/home-manager/starship.nix b/modules/home-manager/starship.nix index 12e7af1..548128e 100644 --- a/modules/home-manager/starship.nix +++ b/modules/home-manager/starship.nix @@ -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") + ); } diff --git a/modules/home-manager/sway.nix b/modules/home-manager/sway.nix index d1b011e..9f8067c 100644 --- a/modules/home-manager/sway.nix +++ b/modules/home-manager/sway.nix @@ -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} + ''; } diff --git a/modules/home-manager/swaylock.nix b/modules/home-manager/swaylock.nix index e0bcc5b..5c99aca 100644 --- a/modules/home-manager/swaylock.nix +++ b/modules/home-manager/swaylock.nix @@ -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) + ); } diff --git a/modules/home-manager/tmux.nix b/modules/home-manager/tmux.nix index f27261c..94a7951 100644 --- a/modules/home-manager/tmux.nix +++ b/modules/home-manager/tmux.nix @@ -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 [ { diff --git a/modules/home-manager/tofi.nix b/modules/home-manager/tofi.nix index bf10a28..5bc0df7 100644 --- a/modules/home-manager/tofi.nix +++ b/modules/home-manager/tofi.nix @@ -1,7 +1,4 @@ -{ config -, lib -, ... -}: +{ config, lib, ... }: let inherit (config.catppuccin) sources; cfg = config.programs.tofi.catppuccin; diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix index 1d64149..057a676 100644 --- a/modules/home-manager/waybar.nix +++ b/modules/home-manager/waybar.nix @@ -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; }) ] ); } diff --git a/modules/home-manager/yazi.nix b/modules/home-manager/yazi.nix index 172bae5..f4b6402 100644 --- a/modules/home-manager/yazi.nix +++ b/modules/home-manager/yazi.nix @@ -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"; diff --git a/modules/home-manager/zathura.nix b/modules/home-manager/zathura.nix index d7fda43..6c50986 100644 --- a/modules/home-manager/zathura.nix +++ b/modules/home-manager/zathura.nix @@ -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 - '')); + '' + ) + ); } diff --git a/modules/home-manager/zellij.nix b/modules/home-manager/zellij.nix index 092ad0c..d6bc3b5 100644 --- a/modules/home-manager/zellij.nix +++ b/modules/home-manager/zellij.nix @@ -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; + }; }; } diff --git a/modules/home-manager/zsh-syntax-highlighting.nix b/modules/home-manager/zsh-syntax-highlighting.nix index 427304a..cb7c35d 100644 --- a/modules/home-manager/zsh-syntax-highlighting.nix +++ b/modules/home-manager/zsh-syntax-highlighting.nix @@ -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 '' diff --git a/modules/lib/default.nix b/modules/lib/default.nix index e57df90..8ed4cd0 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -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 { }; } diff --git a/modules/lib/mkImports.nix b/modules/lib/mkImports.nix index 07c0a7b..6313ea3 100644 --- a/modules/lib/mkImports.nix +++ b/modules/lib/mkImports.nix @@ -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 diff --git a/modules/nixos/console.nix b/modules/nixos/console.nix index 37d20db..c41e3b8 100644 --- a/modules/nixos/console.nix +++ b/modules/nixos/console.nix @@ -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 diff --git a/modules/nixos/globals.nix b/modules/nixos/globals.nix index 0b627fb..0f66e18 100644 --- a/modules/nixos/globals.nix +++ b/modules/nixos/globals.nix @@ -1,4 +1,5 @@ -{ lib, defaultSources, ... }: { +{ lib, defaultSources, ... }: +{ options.catppuccin = { enable = lib.mkEnableOption "Catppuccin globally"; diff --git a/modules/nixos/grub.nix b/modules/nixos/grub.nix index b4994b6..1cc07d4 100644 --- a/modules/nixos/grub.nix +++ b/modules/nixos/grub.nix @@ -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"; diff --git a/modules/nixos/plymouth.nix b/modules/nixos/plymouth.nix index 539ceeb..62a54f2 100644 --- a/modules/nixos/plymouth.nix +++ b/modules/nixos/plymouth.nix @@ -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; }) ]; }; } diff --git a/modules/nixos/sddm.nix b/modules/nixos/sddm.nix index 25bf091..ff0c795 100644 --- a/modules/nixos/sddm.nix +++ b/modules/nixos/sddm.nix @@ -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}"; + }; } diff --git a/test.nix b/test.nix index 59022d1..b2be30d 100644 --- a/test.nix +++ b/test.nix @@ -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()