2024-02-23 06:57:33 +00:00
|
|
|
# Bahaghari's set of library. This requires nixpkgs' package set which has its
|
|
|
|
# library anyways. This set is mostly copied over from nixpkgs' way of doing
|
|
|
|
# things.
|
2024-02-24 02:30:41 +00:00
|
|
|
#
|
2024-02-23 06:57:33 +00:00
|
|
|
# Take note the `lib` attribute throughout all of the library files are
|
|
|
|
# referring to the Bahaghari library set. We mostly rely on `pkgs.lib` as an
|
|
|
|
# easy way to identify if we use nixpkgs' standard library.
|
2024-03-02 10:13:56 +00:00
|
|
|
#
|
|
|
|
# As a design constraint, since this is expected to be evaluated modularly, we
|
|
|
|
# cannot have functions that is expected to be used in `imports` module
|
|
|
|
# attribute such as functions generating a nixpkgs module. Otherwise, we'll
|
|
|
|
# have one of those dastardly infinite recursion error and we'll be requiring
|
|
|
|
# the users to import them through the `specialArgs` module argument. In other
|
|
|
|
# words, this is a strict utility library that is fully usable outside of
|
|
|
|
# nixpkgs module system which is a happy accident. Hoorah for me?
|
|
|
|
#
|
|
|
|
# And another thing, keep the `pkgs` usage down to a minimum and select the
|
|
|
|
# most oft-used packages as much as possible. We want Bahaghari to be a good
|
|
|
|
# citizen of the Nix ecosystem after all and as a result, we have happy users
|
|
|
|
# and happy dev running in a rainbow la-la land.
|
2024-02-24 02:30:41 +00:00
|
|
|
{ pkgs }:
|
|
|
|
|
2024-02-23 06:57:33 +00:00
|
|
|
pkgs.lib.makeExtensible
|
|
|
|
(self:
|
2024-02-25 10:20:13 +00:00
|
|
|
let
|
2024-03-02 10:10:21 +00:00
|
|
|
callLibs = file: import file { inherit (pkgs) lib; inherit pkgs self; };
|
2024-02-25 10:20:13 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
trivial = callLibs ./trivial.nix;
|
|
|
|
hex = callLibs ./hex.nix;
|
2024-02-29 14:06:33 +00:00
|
|
|
math = callLibs ./math.nix;
|
2024-02-24 02:30:41 +00:00
|
|
|
|
2024-05-21 12:42:08 +00:00
|
|
|
# We won't export any of the attributes here as a top-level attribute for
|
|
|
|
# some unbeknownst and probably irrational reason.
|
|
|
|
colors = {
|
|
|
|
rgb = callLibs ./colors/rgb.nix;
|
|
|
|
};
|
|
|
|
|
2024-03-02 10:13:56 +00:00
|
|
|
# Dedicated module sets are not supposed to have any of its functions as a
|
|
|
|
# top-level attribute. It's to make things a bit easier to organize and
|
|
|
|
# maintain. Plus, if there's any functions that are easily applicable
|
|
|
|
# outside of the module set it represents, it should be moved outside of
|
|
|
|
# the namespace.
|
2024-02-25 10:20:13 +00:00
|
|
|
tinted-theming = callLibs ./tinted-theming.nix;
|
2024-02-23 06:57:33 +00:00
|
|
|
|
2024-02-25 10:20:13 +00:00
|
|
|
inherit (self.trivial) importYAML toYAML toBaseDigitsWithGlyphs
|
2024-05-21 12:27:12 +00:00
|
|
|
generateGlyphSet generateConversionTable generateBaseDigitType clamp
|
|
|
|
isNumber scale;
|
2024-02-28 10:39:00 +00:00
|
|
|
|
2024-02-28 10:43:20 +00:00
|
|
|
inherit (self.hex) isHexString;
|
2024-05-30 06:42:29 +00:00
|
|
|
inherit (self.math) abs pow percentage factorial floor ceil round round'
|
|
|
|
summate product;
|
2024-02-25 10:20:13 +00:00
|
|
|
})
|