refactor: use helper funcs for hyprland conf

This commit is contained in:
matt1432 2024-11-20 20:12:24 -05:00
parent 318ccef645
commit 85348d1a6c
13 changed files with 414 additions and 173 deletions

View file

@ -3,15 +3,15 @@
inputs,
}: let
flake = import ./flake inputs;
hypr = import ./hypr inputs.nixpkgs.lib;
strings = import ./strings inputs.nixpkgs.lib;
lib = flake // strings;
lib = flake // hypr // strings;
in
# Expose main attrs
lib
# Expose all funcs
// strings
// flake
// {inherit flake hypr strings;}
# Expose funcs that require pkgs
// perSystem (
pkgs:

57
lib/hypr/default.nix Normal file
View file

@ -0,0 +1,57 @@
{
concatStringsSep,
elemAt,
optionals,
...
}: rec {
pointToStr = p: "${toString (elemAt p 0)}, ${toString (elemAt p 1)}";
mkBezier = {
name,
p0,
p1,
}:
concatStringsSep "," [name (pointToStr p0) (pointToStr p1)];
mkAnimation = {
name,
enable ? true,
duration ? 0, # in ds (100ms)
bezier ? "default",
style ? null,
}:
concatStringsSep "," (
[
name
(
if enable
then "1"
else "0"
)
]
++ optionals enable (
[
(toString duration)
bezier
]
++ optionals (style != null) [style]
)
);
mkLayerRule = {
rule,
namespace,
}:
concatStringsSep "," [rule namespace];
mkBind = {
modifier ? "",
key,
dispatcher ? "exec",
command ? null,
}:
concatStringsSep "," (
[modifier key dispatcher]
++ optionals (command != null) [command]
);
}

View file

@ -1,5 +1,5 @@
{
concatStringsSep,
concatStrings,
stringToCharacters,
substring,
tail,
@ -7,5 +7,5 @@
...
}: {
mkVersion = src: "0.0.0+" + src.shortRev;
capitalise = str: (toUpper (substring 0 1 str) + (concatStringsSep "" (tail (stringToCharacters str))));
capitalise = str: (toUpper (substring 0 1 str) + (concatStrings (tail (stringToCharacters str))));
}