diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b742f73..9397714 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,8 @@ Create a file in `modules//` with the name of the port. All ports should the `catppuccin.enable` and `catppuccin.flavor` options, and optionally the `catppuccin.accent` option. `catppuccin.flavor` and `catppuccin.accent` should default to `config.catppuccin.flavor` and `config.catppuccin.accent`, respectively. +When you're done, make sure to add your new file to the list in +`modules//all-modules.nix` [npins](https://github.com/andir/npins) is used to track our upstream sources to use in modules. This allows us to easily access and auto-update all themes. diff --git a/dev/flake.nix b/dev/flake.nix index f00b1d2..688f2c4 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -105,12 +105,12 @@ { nixos-doc = mkOptionDoc { inherit version; - modules = [ ../modules/nixos ]; + moduleRoot = ../modules/nixos; }; home-manager-doc = mkOptionDoc { inherit version; - modules = [ ../modules/home-manager ]; + moduleRoot = ../modules/home-manager; }; site = mkSite { diff --git a/docs/options-doc.nix b/docs/options-doc.nix index 66d9d05..b84656c 100644 --- a/docs/options-doc.nix +++ b/docs/options-doc.nix @@ -1,30 +1,57 @@ { 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; - }; +{ + version, + modules ? [ moduleRoot ], + moduleRoot, +}: +let + baseDeclarationUrl = "https://github.com/catppuccin/nix/blob/main"; + declarationIsOurs = declaration: lib.hasPrefix (toString moduleRoot) (toString declaration); + declarationSubpath = declaration: lib.removePrefix (toString ../. + "/") (toString declaration); - config = { - _module.check = false; - }; - } - ]; - }).options - [ - "_module" - "system" - ]; + toGithubDeclaration = + declaration: + let + subpath = declarationSubpath declaration; + in + { + url = "${baseDeclarationUrl}/${subpath}"; + name = ""; + }; - transformOptions = opt: builtins.removeAttrs opt [ "declarations" ]; + evaluated = lib.evalModules { + modules = modules ++ [ + { + options.system.nixos.release = lib.mkOption { + type = lib.types.str; + default = lib.trivial.release; + readOnly = true; + }; - documentType = "none"; - revision = version; -}).optionsCommonMark + config = { + _module.check = false; + }; + } + ]; + }; + + optionsDoc = nixosOptionsDoc { + options = builtins.removeAttrs evaluated.options [ + "_module" + "system" + ]; + + transformOptions = + opt: + opt + // { + declarations = map ( + declaration: if declarationIsOurs declaration then toGithubDeclaration declaration else declaration + ) opt.declarations; + }; + + documentType = "none"; + revision = version; + }; +in +optionsDoc.optionsCommonMark diff --git a/modules/home-manager/all-modules.nix b/modules/home-manager/all-modules.nix new file mode 100644 index 0000000..800dc31 --- /dev/null +++ b/modules/home-manager/all-modules.nix @@ -0,0 +1,43 @@ +[ + ./alacritty.nix + ./bat.nix + ./bottom.nix + ./btop.nix + ./cava.nix + ./delta.nix + ./dunst.nix + ./fcitx5.nix + ./fish.nix + ./foot.nix + ./fzf.nix + ./gh-dash.nix + ./gitui.nix + ./glamour.nix + ./globals.nix + ./gtk.nix + ./helix.nix + ./hyprland.nix + ./imv.nix + ./k9s.nix + ./kitty.nix + ./kvantum.nix + ./lazygit.nix + ./mako.nix + ./micro.nix + ./mpv.nix + ./neovim.nix + ./polybar.nix + ./rio.nix + ./rofi.nix + ./skim.nix + ./starship.nix + ./swaylock.nix + ./sway.nix + ./tmux.nix + ./tofi.nix + ./waybar.nix + ./yazi.nix + ./zathura.nix + ./zellij.nix + ./zsh-syntax-highlighting.nix +] diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 4987c64..3501a10 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,4 +1,12 @@ -{ lib, pkgs, ... }@args: { - imports = import ../lib/mkImports.nix args ./.; + config, + lib, + pkgs, + ... +}: +{ + imports = import ../lib/import-modules.nix { + inherit config lib pkgs; + modules = import ./all-modules.nix; + }; } diff --git a/modules/home-manager/globals.nix b/modules/home-manager/globals.nix index dbe97a7..5189a93 100644 --- a/modules/home-manager/globals.nix +++ b/modules/home-manager/globals.nix @@ -1,4 +1,4 @@ -{ lib, defaultSources, ... }: +{ lib, ... }: { options.catppuccin = { enable = lib.mkEnableOption "Catppuccin globally"; @@ -15,14 +15,18 @@ description = "Global Catppuccin accent"; }; - sources = lib.mkOption { - type = lib.types.lazyAttrsOf lib.types.raw; - default = defaultSources; - defaultText = "{ ... }"; - # HACK! - # without this, overriding one source will delete all others. -@getchoo - apply = lib.recursiveUpdate defaultSources; - description = "Port sources used across all options"; - }; + sources = + let + defaultSources = import ../../.sources; + in + lib.mkOption { + type = lib.types.lazyAttrsOf lib.types.raw; + default = defaultSources; + defaultText = "{ ... }"; + # HACK! + # without this, overriding one source will delete all others. -@getchoo + apply = lib.recursiveUpdate defaultSources; + description = "Port sources used across all options"; + }; }; } diff --git a/modules/lib/import-modules.nix b/modules/lib/import-modules.nix new file mode 100644 index 0000000..90b36a2 --- /dev/null +++ b/modules/lib/import-modules.nix @@ -0,0 +1,19 @@ +{ + modules, + config, + lib, + pkgs, + ... +}: +let + toModule = file: { + _file = file; + imports = [ + (import file { + inherit config pkgs; + lib = import ./mk-ext-lib.nix { inherit config lib pkgs; }; + }) + ]; + }; +in +map toModule modules diff --git a/modules/lib/mk-ext-lib.nix b/modules/lib/mk-ext-lib.nix new file mode 100644 index 0000000..55f39e8 --- /dev/null +++ b/modules/lib/mk-ext-lib.nix @@ -0,0 +1,14 @@ +{ + config, + lib, + pkgs, + ... +}: +lib.extend ( + final: _: { + ctp = import ./. { + inherit config pkgs; + lib = final; + }; + } +) diff --git a/modules/lib/mkImports.nix b/modules/lib/mkImports.nix deleted file mode 100644 index 6313ea3..0000000 --- a/modules/lib/mkImports.nix +++ /dev/null @@ -1,24 +0,0 @@ -# this imports all files in a directory (besides default.nix) -# with our modified arguments -{ lib, pkgs, ... }@args: -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; }); }); - - defaultSources = import ../../.sources; - } - ); -in -lib.pipe dir [ - builtins.readDir - builtins.attrNames - (lib.remove "default.nix") - (map applyImports) -] diff --git a/modules/nixos/all-modules.nix b/modules/nixos/all-modules.nix new file mode 100644 index 0000000..de89b52 --- /dev/null +++ b/modules/nixos/all-modules.nix @@ -0,0 +1,7 @@ +[ + ./console.nix + ./globals.nix + ./grub.nix + ./plymouth.nix + ./sddm.nix +] diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 4987c64..3501a10 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,4 +1,12 @@ -{ lib, pkgs, ... }@args: { - imports = import ../lib/mkImports.nix args ./.; + config, + lib, + pkgs, + ... +}: +{ + imports = import ../lib/import-modules.nix { + inherit config lib pkgs; + modules = import ./all-modules.nix; + }; } diff --git a/modules/nixos/globals.nix b/modules/nixos/globals.nix index dbe97a7..5189a93 100644 --- a/modules/nixos/globals.nix +++ b/modules/nixos/globals.nix @@ -1,4 +1,4 @@ -{ lib, defaultSources, ... }: +{ lib, ... }: { options.catppuccin = { enable = lib.mkEnableOption "Catppuccin globally"; @@ -15,14 +15,18 @@ description = "Global Catppuccin accent"; }; - sources = lib.mkOption { - type = lib.types.lazyAttrsOf lib.types.raw; - default = defaultSources; - defaultText = "{ ... }"; - # HACK! - # without this, overriding one source will delete all others. -@getchoo - apply = lib.recursiveUpdate defaultSources; - description = "Port sources used across all options"; - }; + sources = + let + defaultSources = import ../../.sources; + in + lib.mkOption { + type = lib.types.lazyAttrsOf lib.types.raw; + default = defaultSources; + defaultText = "{ ... }"; + # HACK! + # without this, overriding one source will delete all others. -@getchoo + apply = lib.recursiveUpdate defaultSources; + description = "Port sources used across all options"; + }; }; }