Initial checkin
This commit is contained in:
commit
815750e93e
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
description = "Nix-to-EDN converter.";
|
||||
|
||||
input = { nixpkgs.url = "nixpkgs/nixos-21.05"; };
|
||||
|
||||
outputs = { self, nixpkgs }: {
|
||||
lib = { toEDN = import ./to-edn.nix { inherit (nixpkgs) lib; }; };
|
||||
};
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{ lib }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
join-str = concatStringsSep " ";
|
||||
toEDN = ds:
|
||||
if isString ds then
|
||||
''"${ds}"''
|
||||
else
|
||||
(if isInt ds then
|
||||
ds
|
||||
else
|
||||
(if isList ds then
|
||||
"[ ${join-str (map toEDN ds)} ]"
|
||||
else
|
||||
(if isAttrs ds then
|
||||
"{ ${join-str (mapAttrs (k: v: ":${k} ${toEDN v}") ds)} }"
|
||||
else
|
||||
throw "unsupported type: ${builtins.typeOf ds}: ${ds}")));
|
||||
|
||||
in { ds }: toEDN ds
|
Loading…
Reference in New Issue