feat(modules): add declarations (#198)
This commit is contained in:
parent
ed79a45b47
commit
296adaf933
12 changed files with 188 additions and 76 deletions
|
@ -6,6 +6,8 @@ Create a file in `modules/<module>/` 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/<module>/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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 = "<catppuccin/${subpath}>";
|
||||
};
|
||||
|
||||
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
|
||||
|
|
43
modules/home-manager/all-modules.nix
Normal file
43
modules/home-manager/all-modules.nix
Normal file
|
@ -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
|
||||
]
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
19
modules/lib/import-modules.nix
Normal file
19
modules/lib/import-modules.nix
Normal file
|
@ -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
|
14
modules/lib/mk-ext-lib.nix
Normal file
14
modules/lib/mk-ext-lib.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
lib.extend (
|
||||
final: _: {
|
||||
ctp = import ./. {
|
||||
inherit config pkgs;
|
||||
lib = final;
|
||||
};
|
||||
}
|
||||
)
|
|
@ -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)
|
||||
]
|
7
modules/nixos/all-modules.nix
Normal file
7
modules/nixos/all-modules.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
./console.nix
|
||||
./globals.nix
|
||||
./grub.nix
|
||||
./plymouth.nix
|
||||
./sddm.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;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue