:fn-container-comment: footnote:[IDK why would someone do this with Bahaghari but whatever, your system, your rules.]
:fn-specialization-comment: footnote:[Which I can see is useful for separating rices and booting into them separately for whatever reason (again, your system, your rules but my guess is because you're a control freak).]
Bahaghari footnote:[Tagalog word for "rainbow" or a "king's loincloth" if you prefer.] is a specialized set of Nix modules for generating and applying themes.
To get started using Bahaghari, you have to set some things up first.
The way how Bahaghari expects you to use it is by choosing one (or more if you want) of the module sets which you can view more details at <<module-sets, its dedicated section>>.
For now, let's assume that you are using Tinted Theming module set (which is basically the most developed out of all of them) in your NixOS configuration which you can set it up with the following code.
* You can import the dependencies with a pinning tool (that is not flakes) like https://github.com/nmattia/niv[niv] or https://github.com/andir/npins[npins].
* You could install it with https://zero-to-nix.com/concepts/flakes[Nix flakes], an experimental feature featuring a built-in way of pinning them dependencies.
If for whatever reason you need Bahaghari library outside of using it with Bahaghari (for example, you want to use the math subset), you can also import it yourself.
This module is designed to closely follow Tinted Theming's standard while offering some convenience with the library set.
For example, you can use `importYAML` from Bahaghari's standard library set to easily import standard Base16 schemes into Nix-representable data which you can press onto your Nix configuration.
However, Bahaghari has a dedicated set of library functions in `bahaghariLib.tinted-theming` to make interacting with this module set a bit easier.
For example, instead of using `importYAML`, you can use `tinted-theming.importScheme` instead which the function will also take care of modernizing legacy Base16 schemes if it detected as one.
Bahaghari offers a pre-configured version of already existing modules for NixOS, home-manager, and NixVim quite similar to Stylix's `stylix.targets.<name>` submodules.
To make use of this, you'll have to import Bahaghari module set's
Most notably, the feature I'm looking for is generating multiple colorscheme templates for different applications which is nice for hybrid deployments of home-manager-plus-mutable-configurations (AKA traditional dotfiles) and for mixed installations of NixOS and home-manager (or whatever else that can be combined).
While Bahaghari eventually diverged from nix-colors entirely, it can be used as an alternative specifically with Bahaghari's Tinted Theming module set.
You can replicate nix-colors' preference of allowing a default set of colorscheme by creating a module argument holding the name of the preferred colorscheme.
While Bahaghari can be used similarly to Stylix, it isn't completely 1-to-1 to Stylix as the latter focuses on the holistic side of customization including for fonts and wallpaper.
On the other hand, Bahaghari completely focuses on colorscheme generation. footnote:[While Bahaghari as a project can also focus beyond colorschemes similar to Stylix, it isn't a part of the vision for now.]
An interesting thing to note: being a project where it exposes a Nix module and a library set, we actually don't use flakes for pinning our supported branches of nixpkgs and/or NixOS as much as we don't want to be fully locked into that feature and will also limit support for non-flake usage especially if a potential contributor doesn't use flakes.
Instead, we use a different pinning tool with https://github.com/andir/npins[npins].
Please see its homepage for more information on using it.
[#library-development]
=== Library development
A large part of Bahaghari is its library.
There's actually two top-level directories that you have to keep in mind: `lib` and `utils`.
Bahaghari separates its function set as either part of the library subset or utilities subset patterned after the NixOS environment of adding `utils` module argument.
The main difference between these two is the utilities subset depends on the environment configuration (for example, using `config.bahaghari.tinted-theming.schemes`) while those in library subset does not.
This project comes with a test suite for... testing things.
You know, for the purpose of preventing as much regression and catching as many potential bugs before releasing this for the users.
For the Bahaghari library set, we have a testing infrastructure set all set in link:./tests/[`./tests/`].
This relies on the `lib.debug.runTests` from nixpkgs which is enough for our simple needs of making sure the functions are correct.
To run the test suite, here's one way to do it.footnote:test-setup-assumption[Assuming you have the new Nix CLI and have nixpkgs as part of `NIX_PATH`.]
We also have a test suites for the Nix module sets.
Similarly from the library set testing, it relies on nixpkgs' NixOS test integration.footnote:[For now, we only test these with NixOS since most of Bahaghari is environment-agnostic anyways. We're more concerned if it can used as intended.]
You can test those puppies out with the following command.footnote:test-setup-assumption[]