summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-06-19 15:32:57 -0400
committerFreya Murphy <freya@freyacat.org>2025-06-19 15:32:57 -0400
commitd0e672386d7a756e7c7bc2a5530a00801fe203c9 (patch)
tree1864dfe3a8ec0492e3ef939efb2a10484e76cf4d
parentupdate astal notifications (diff)
downloaddotfiles-nix-d0e672386d7a756e7c7bc2a5530a00801fe203c9.tar.gz
dotfiles-nix-d0e672386d7a756e7c7bc2a5530a00801fe203c9.tar.bz2
dotfiles-nix-d0e672386d7a756e7c7bc2a5530a00801fe203c9.zip
add libs to flake
Diffstat (limited to '')
-rw-r--r--flake.nix11
-rw-r--r--lib/default.nix5
-rw-r--r--lib/lua.nix32
3 files changed, 47 insertions, 1 deletions
diff --git a/flake.nix b/flake.nix
index b5e70c1..0088f41 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,6 +31,7 @@
};
outputs = {
+ self,
nixpkgs,
flake-utils,
...
@@ -58,9 +59,17 @@
kaworu = nixosConfigurations.kaworu.config.home-manager.users.${options.user}.home;
};
+ lib = import ./lib {
+ inherit inputs options;
+ inherit (nixpkgs) lib;
+ };
+
packages = perSystem (
pkgs: system:
- import ./pkgs {inherit pkgs inputs system options;}
+ import ./pkgs {
+ inherit pkgs inputs system options;
+ inherit (nixpkgs) lib;
+ }
);
legacyPackages = packages;
diff --git a/lib/default.nix b/lib/default.nix
new file mode 100644
index 0000000..574a348
--- /dev/null
+++ b/lib/default.nix
@@ -0,0 +1,5 @@
+{...} @ inputs: let
+ callLibs = file: import file inputs;
+in {
+ lua = callLibs ./lua.nix;
+}
diff --git a/lib/lua.nix b/lib/lua.nix
new file mode 100644
index 0000000..704cdfa
--- /dev/null
+++ b/lib/lua.nix
@@ -0,0 +1,32 @@
+{lib, ...}: let
+ fmt = val:
+ # nil
+ if val == null
+ then "nil"
+ # boolean
+ else if builtins.isBool val
+ then
+ if val
+ then "true"
+ else "false"
+ # number
+ else if builtins.isInt val || builtins.isFloat val
+ then toString val
+ # string
+ else if builtins.isString val
+ then "'${val}'"
+ # table (array)
+ else if builtins.isList val
+ then "{ " + (lib.concatStringsSep ", " (map fmt val)) + " }"
+ # table (object)
+ else if builtins.isAttrs val
+ then
+ "{ "
+ + (lib.concatStringsSep ", "
+ (lib.mapAttrsToList (k: v: "${k} = ${fmt v}") val))
+ + " }"
+ # invalid
+ else throw "Unsupported value: ${toString val}";
+in {
+ fmt = fmt;
+}