Palette library integrated + polybar and alacritty

This commit is contained in:
Filippo Berto 2021-06-11 00:20:03 +02:00
parent a61bfe3c50
commit ef5b48d142
17 changed files with 1090 additions and 214 deletions

45
extra/float/default.nix Normal file
View file

@ -0,0 +1,45 @@
{ pkgs, lib ? pkgs.lib, ... }:
let
inherit (builtins) head tail isFloat isInt;
inherit (lib.strings) toInt match splitString;
floatComponents = f: splitString "." (toString f);
in
rec {
# Force a number to be a float (hacky but works)
ensureFloat = v:
assert (isInt v || isFloat v);
v + 0.1 - 0.1;
# Convert integer to float (hacky but it works)
fromInt = i:
assert isInt i;
ensureFloat i;
# Round float to upper integer
ceil = f:
let
comp = floatComponents f;
int = toInt (head comp);
inc = if match "[1-9][[:digit:]]*" (head (tail comp)) != null then 1 else 0;
in
assert(isFloat f);
int + inc;
# Round float to lower integer
floor = f:
let
int = toInt (head (floatComponents f));
in
assert(isFloat f);
int;
# Round float to closest integer
round = f:
let
comp = floatComponents (ensureFloat f);
int = toInt (head comp);
inc = if match "[5-9][[:digit:]]*" (head (tail comp)) != null then 1 else 0;
in
int + inc;
}