diff --git a/escape.nix b/escape.nix index d207702..0805d9d 100644 --- a/escape.nix +++ b/escape.nix @@ -10,7 +10,7 @@ lib: let yeet = string: builtins.unsafeDiscardStringContext (builtins.unsafeDiscardOutputDependency string); getContent = drvPath: let - drv = builtins.readFile drvPath; + drv = lib.readFile drvPath; isValid = builtins.match ".*${lib.escapeRegex startMarker}.*${lib.escapeRegex endMarker}.*" drv != null; content = lib.pipe drv [ (lib.splitString startMarker) @@ -40,7 +40,7 @@ lib: let final = recurseSubDrv ctxNames [ string ]; final' = assert (lib.length final == 1); lib.head final; in if builtins.hasContext string then - builtins.replaceStrings [ ''\"'' ''\n'' ] [ ''"'' "\n" ] (yeet final') + lib.replaceStrings [ ''\"'' ''\n'' ] [ ''"'' "\n" ] (yeet final') else lib.strings.escapeXML string; diff --git a/flake.nix b/flake.nix index 32613b1..593455c 100644 --- a/flake.nix +++ b/flake.nix @@ -6,19 +6,18 @@ outputs = { self, nixpkgslib }: let inherit (nixpkgslib) lib; - first = n: builtins.substring 0 n; - dropFirst = n: string: builtins.substring n (builtins.stringLength string - n) string; + first = n: lib.substring 0 n; + dropFirst = n: string: lib.substring n (lib.stringLength string - n) string; - last = n: string: builtins.substring (builtins.stringLength string - n) n string; - dropLast = n: string: builtins.substring 0 (builtins.stringLength string - n) string; + last = n: string: lib.substring (lib.stringLength string - n) n string; + dropLast = n: string: lib.substring 0 (lib.stringLength string - n) string; escapix = import ./escape.nix lib; inherit (escapix) escape; attrsetToHtmlAttrs = attrs: - builtins.concatStringsSep " " - (builtins.attrValues - (builtins.mapAttrs (k: v: ''${k}="${escape (toString v)}"'') attrs)); + lib.concatStringsSep " " + (lib.mapAttrsToList (k: v: ''${k}="${escape (toString v)}"'') attrs); dottedNameToTag = name: if first 1 name == "." @@ -44,7 +43,7 @@ __functor = this: next: # Not an attrset. Just add it onto the HTML. - if !builtins.isAttrs next + if !lib.isAttrs next then this // { outPath = (toString this) + escape (toString next); } @@ -61,7 +60,7 @@ # This will output the following HTML: # # - else if builtins.isAttrs next && !(next ? outPath) + else if lib.isAttrs next && !(next ? outPath) then let lastElementIsTag = last 1 (toString this) == ">"; lastElementIsSelfClosing = last 2 (toString this) == "/>";