mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-03-14 18:18:59 +00:00
bahaghari/lib/trivial: add toYAML
and toBaseDigitsWithGlyphs
This commit is contained in:
parent
6c5e359fc3
commit
0af7a31d7b
@ -16,6 +16,6 @@ pkgs.lib.makeExtensible
|
|||||||
hex = callLibs ./hex.nix;
|
hex = callLibs ./hex.nix;
|
||||||
tinted-theming = callLibs ./tinted-theming.nix;
|
tinted-theming = callLibs ./tinted-theming.nix;
|
||||||
|
|
||||||
inherit (self.trivial) importYAML;
|
inherit (self.trivial) importYAML toYAML toBaseDigitsWithGlyphs;
|
||||||
inherit (self.hex) toHexString;
|
inherit (self.hex) toHexString;
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
{ pkgs, lib }:
|
{ pkgs, lib }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
inherit (pkgs.lib.generators) toYAML;
|
||||||
|
|
||||||
/* Read YAML files into a Nix expression similar to lib.importJSON and
|
/* Read YAML files into a Nix expression similar to lib.importJSON and
|
||||||
lib.importTOML from nixpkgs standard library. Unlike both of them, this
|
lib.importTOML from nixpkgs standard library. Unlike both of them, this
|
||||||
unfortunately relies on an import-from-derivation (IFD) so it isn't exactly
|
unfortunately relies on an import-from-derivation (IFD) so it isn't exactly
|
||||||
@ -11,7 +13,7 @@
|
|||||||
|
|
||||||
https://pkg.go.dev/gopkg.in/yaml.v3#readme-compatibility
|
https://pkg.go.dev/gopkg.in/yaml.v3#readme-compatibility
|
||||||
|
|
||||||
Type: importYAML :: path -> any
|
Type: importYAML :: Path -> any
|
||||||
*/
|
*/
|
||||||
importYAML = path:
|
importYAML = path:
|
||||||
let
|
let
|
||||||
@ -20,4 +22,25 @@
|
|||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
pkgs.lib.importJSON data;
|
pkgs.lib.importJSON data;
|
||||||
|
|
||||||
|
/* Convert a given decimal number to a specified base digit with the set of
|
||||||
|
glyphs for each digit as returned from lib.toBaseDigits.
|
||||||
|
|
||||||
|
Type: toBaseDigitWithGlyphs :: Int -> Int -> Attrs -> String
|
||||||
|
|
||||||
|
Example:
|
||||||
|
toBaseDigitWithGlyphs 24 267 {
|
||||||
|
"0" = "0";
|
||||||
|
# ...
|
||||||
|
"22" = "L";
|
||||||
|
"23" = "M";
|
||||||
|
"24" = "N";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
toBaseDigitsWithGlyphs = base: i: glyphs:
|
||||||
|
let
|
||||||
|
baseDigits = pkgs.lib.toBaseDigits i;
|
||||||
|
toBaseDigits = d: glyphs.${builtins.toString i};
|
||||||
|
in
|
||||||
|
pkgs.lib.concatMapStrings toBaseDigits baseDigits;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user