summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix5
-rw-r--r--lib/files.nix23
-rw-r--r--lib/lua.nix10
3 files changed, 32 insertions, 6 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 574a348..d342bf8 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -1,5 +1,8 @@
{...} @ inputs: let
callLibs = file: import file inputs;
-in {
lua = callLibs ./lua.nix;
+ files = callLibs ./files.nix;
+in {
+ inherit (lua) toLua;
+ inherit (files) getFiles certs sshKeys gpgKeys;
}
diff --git a/lib/files.nix b/lib/files.nix
new file mode 100644
index 0000000..18439d9
--- /dev/null
+++ b/lib/files.nix
@@ -0,0 +1,23 @@
+{lib, ...}: let
+
+ # gets list of files from a directory
+ getFiles = folder:
+ lib.attrsets.mapAttrsToList (name: type: "${folder}/${name}") (builtins.readDir folder);
+
+ # gets custom set of root certs
+ certs = getFiles ../files/certs;
+
+ # set of ssh keys
+ sshKeys = builtins.filter
+ (path: lib.strings.hasSuffix "pub" path) (getFiles ../files/keys);
+
+ # set of gpg keys
+ gpgKeys = builtins.filter
+ (path: lib.strings.hasSuffix "asc" path) (getFiles ../files/keys);
+
+in {
+ inherit getFiles;
+ inherit certs;
+ inherit sshKeys;
+ inherit gpgKeys;
+}
diff --git a/lib/lua.nix b/lib/lua.nix
index 704cdfa..6f6389e 100644
--- a/lib/lua.nix
+++ b/lib/lua.nix
@@ -1,6 +1,6 @@
{lib, ...}: let
- fmt = val:
- # nil
+ toLua = val:
+ # nil
if val == null
then "nil"
# boolean
@@ -17,16 +17,16 @@
then "'${val}'"
# table (array)
else if builtins.isList val
- then "{ " + (lib.concatStringsSep ", " (map fmt val)) + " }"
+ then "{ " + (lib.concatStringsSep ", " (map toLua val)) + " }"
# table (object)
else if builtins.isAttrs val
then
"{ "
+ (lib.concatStringsSep ", "
- (lib.mapAttrsToList (k: v: "${k} = ${fmt v}") val))
+ (lib.mapAttrsToList (k: v: "${k} = ${toLua v}") val))
+ " }"
# invalid
else throw "Unsupported value: ${toString val}";
in {
- fmt = fmt;
+ inherit toLua;
}