diff options
author | Freya Murphy <freya@freyacat.org> | 2025-06-24 11:51:39 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-06-24 11:51:39 -0400 |
commit | d639c293ad1ba71008aeb5c54c40f59a076018dc (patch) | |
tree | e832a3f0ee5044c8b35e5642f07a62137bbffc2c /lib | |
parent | update ssh config (diff) | |
download | dotfiles-nix-d639c293ad1ba71008aeb5c54c40f59a076018dc.tar.gz dotfiles-nix-d639c293ad1ba71008aeb5c54c40f59a076018dc.tar.bz2 dotfiles-nix-d639c293ad1ba71008aeb5c54c40f59a076018dc.zip |
redo lib, make global vars for key lists
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 5 | ||||
-rw-r--r-- | lib/files.nix | 23 | ||||
-rw-r--r-- | lib/lua.nix | 10 |
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; } |